python对文件的简单操作

来源:互联网 发布:手机翻译软件推荐 编辑:程序博客网 时间:2024/05/17 22:58

python文件的读写

\#encoding=utf8fc = open("./testopen.txt","w")content='"我是文件的内容"'fc.write(content)fc.close()fr = open("./testopen.txt","r")while True:    line = fr.readline()    if len(line)==0:        break    print linefr.close()

需要注意不要丢了第一行的编码方式

0 0