python 以 utf-8 格式写文件 import codecs f = codecs.open('test.txt', 'w', 'utf-8') f.write('中文') f.close() 运行结果: