目录

python-以-utf-8-格式写文件

python 以 utf-8 格式写文件

https://img-home.csdnimg.cn/images/20240715101418.png

关键词由CSDN通过智能技术生成

python 以 utf-8 格式写文件

import codecs
f = codecs.open('test.txt', 'w', 'utf-8')
f.write('中文')
f.close()