This topic created in 4046 days ago, the information mentioned may be changed or developed.
每一次都清除原有文件内容,再写入新内容。以 w 方式打开文件只能在打开的时候覆盖原有内容。
6 replies • 2015-10-14 10:37:56 +08:00
 |
|
w+
|
 |
|
fobj=open("filename","a") fobj.write("msg") fobj.flush() fobj.close()
|
 |
|
r+
f.seek(0) f.write("...") f.truncate()
必须保证文件存在
|
 |
|
seek()
|