Python 文件写操作

Python 文件写操作


#文件写模式
f=open('a.txt','w',encoding='utf-8')
#文件写
f.write('11111 ')
f.write('2222 ')
f.write('3333 4444 ')
#文件写多行
f.writelines(['a ','b ','c '])
#关闭
f.close()