python cookbook 5.1 读写文本数据

#你需要读写各种不同编码的文本数据,比如ASCII,UTF-8,UTF-16等,使用带有rt的open()函数读写文本文件 with open('somefile.txt','rt') as f: data = f.read() with open('somefile.txt','rt') as f: for line in f: pass #类似,为了写入一个文本
相关文章
相关标签/搜索