📌  相关文章
📜  如何将 python 列表保存到文件 - Python 代码示例

📅  最后修改于: 2022-03-11 14:45:34.755000             🧑  作者: Mango

代码示例3
# define list of places
places = ['Berlin', 'Cape Town', 'Sydney', 'Moscow']

with open('listfile.txt', 'w') as filehandle:
    for listitem in places:
        filehandle.write('%s\n' % listitem)