保存数据到txt

join用的不错

a = "Hello, world"
b = "你好,世界"
c = "How are you?"
with open(file='a.txt', mode='w', encoding='utf-8') as f:
    f.write('\n'.join([a, b, c]))
    f.write('\n' + '=' * 30)

 

posted @ 2019-11-20 17:57  市丸银  阅读(304)  评论(0编辑  收藏  举报