编码

1.支持中文

# coding:UTF-8
import codecs    #默认文件读写编码为ASCII

# f=open('a.txt',"w")
# f.write("hello wrold")
# f.close()

content=u"我的世界aaa"
f=codecs.open('a.txt','w',"utf-8")   #设置文件编码
f.write(content)
f.close();
原文地址:https://www.cnblogs.com/zhuxiang1633/p/8848909.html