您的位置:首页 > 其它

ascii文件转为utf-8格式

2016-07-08 18:15 309 查看
import codecs
import os
     #格式转换
fhanzi1 = codecs.open(os.path.join(outputpath,"hanzi1.txt"),"r")
fhanzi = codecs.open(os.path.join(outputpath,"hanzi.txt"),"w")

result_f = codecs.EncodedFile(fhanzi1,'utf-8','gbk')

for chars in result_f:
fhanzi.write(chars)

fhanzi1.close()
fhanzi.close()

os.remove(os.path.join(outputpath,"hanzi1.txt"))


  
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: