编码

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();

 

posted @ 2018-04-15 18:42  fight139  阅读(116)  评论(0编辑  收藏  举报