读写文件,python. learn python the hard way
2017-03-12 08:54
309 查看
#coding=utf-8 poem = "\t I'm trying to writ this into my file,,ooo" def method_one(): f = open('new.txt', 'w') #open new.txt as file 确认在终端,你已经cd进入了文件所在文件夹。否则Open不出来 f.write(poem) #write poem into f f.close() #close my file def method_two(): from sys import argv script, new = argv f = open(new, 'w') f.write(poem) f.close() method_two()
相关文章推荐
- Learn Python The Hard Way学习(16) - 读写文件
- 【Python】Learn Python the hard way, ex16 读写文件
- Learn Python The Hard Way学习(16) - 读写文件
- 【Python】Learn Python the hard way, ex15 读取文件
- Learn Python The Hard Way学习(20) - 函数和文件
- 【Python】Learn Python the hard way, ex17 文件复制
- Learn Python The Hard Way学习(17) - 更多的文件操作
- 【Python】Learn Python the hard way, ex20 用函数读文件readline
- 函数与文件-习题20--learn python the hard way
- Learn Python The Hard Way学习(15) - 读取文件
- Learn Python The Hard Way学习(0) - 安装
- Learn Python The Hard Way学习(12) - 输入提示
- Learn Python The Hard Way学习(2) - 注释和#号
- Learn Python The Hard Way学习(6) - 字符串和文本
- 学习python 好书Learn Python The Hard Way
- Learn Python The Hard Way学习(9) - 打印,打印,打印
- Learn Python The Hard Way学习(13) - 参数,解包,变量
- Learn Python The Hard Way学习(5) - 更多的变量和打印
- Learn Python The Hard Way学习(21) - 函数可以返回信息
- Learn Python The Hard Way学习(7) - 更多的打印