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() 

 

 
 
 
 
 
 
 
 
 
 
 
 
 

相关文章:

  • 2022-12-23
  • 2021-10-09
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-08-14
  • 2021-10-19
猜你喜欢
  • 2022-01-02
  • 2021-11-02
  • 2022-12-23
  • 2022-01-03
  • 2022-12-23
  • 2021-09-29
相关资源
相似解决方案