且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

将列表保存到文件

更新时间:2022-05-09 21:36:08

要保存到文件,您必须在Write-Append模式下将其打开.

In order to save to a file, you have to open it in Write-Append mode.

library_file = open("a.txt", "a")
...
library_file.write("Some string\n")
...
library_file.close()

有关更多信息,请参阅内置函数上的Python文档.

Refer to Python's documentation on Built-in Functions for more information.