python保存字符串到txt文件 str = ('123456') fh = open('666.txt', 'w', encoding='utf-8') fh.write(str) fh.close()