文件的读写操作

边读边写:

 1 oldFile = open("itcast.txt", "r", encoding="utf-8")
 2 newFile = open("itcast_backup.txt", "w", encoding="utf-8")
 3 while True:
 4     ret = oldFile.read(1024)
 5     if ret:
 6         newFile.write(ret)
 7     else:
 8         break
 9 oldFile.close()
10 newFile.close()
原文地址:https://www.cnblogs.com/SP-0306/p/10907519.html