1、注意在windows中文件路径中反斜杠需在前面加反斜杠转义
2、读文本文件的使用:
with open(filename,mode) as f:
for name in f:
print(name)
3、写文本文件:
f.write(str)
注意:w模式会把文件内容全部删除重新写入,a模式则会追加。
Python文件读写的使用
原文:https://www.cnblogs.com/Treelight/p/9741274.html