如何 append 到文件而不是覆盖它?
最佳答案
在 open()
中设置模式到 "a"
(追加)而不是 "w"
(写入):
with open("test.txt", "a") as myfile:
myfile.write("appended text")
documentation列出所有可用的模式。
关于python - 如何 append 到文件?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4706499/