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)