参考:https://www.cnblogs.com/Anita9002/p/7977707.html with open('data.txt','w') as f: f.write('\n'.join(list_data))