当前位置:主页 > 软件编程 > Python代码 >

python指定写入文件时的编码格式方法

时间:2021-05-08 09:05:02 | 栏目:Python代码 | 点击:

实例如下:

#encoding=utf-8
content=u"广东松炀再生资源股份有限"
content=content.encode("utf-8")#写入的文件编码格式为utf-8
with open("testbianma.txt","w")as f:
 f.write(content)

您可能感兴趣的文章:

相关文章