Python writelines()函数

code
f = open('a.txt', 'r')
n = open('b.txt','w+')
n.writelines(f.readlines())
n.close()
f.close()
code
f = open("a.txt", 'w')
f.write("写入一行新数据")
f.flush()
 
code
f = open("a.txt", 'w',buffering = 0)
f.write("写入一行新数据")
 
code
f = open("a.txt", 'w')
f.write("写入一行新数据")
f.close()
code
f = open("a.txt", 'a')
f.write("\n写入一行新数据")
f.close() 

 

 
 
 
 
 
 
 
 
 
 
 
 
 

posted @ 2020-12-23 22:22  anobscureretreat  阅读(370)  评论(0编辑  收藏  举报