记事本默认是ANSI的默认是GBK,需要转码,见下:
f=open("d:\python.txt","r")
content=f.read()
w= content.decode('gbk').encode('utf-8')
print w
f.close()
记事本默认是ANSI的默认是GBK,需要转码,见下:
f=open("d:\python.txt","r")
content=f.read()
w= content.decode('gbk').encode('utf-8')
print w
f.close()
转载于:https://www.cnblogs.com/wlyd/p/5662564.html