标签:blog strong www alt size img 分享 代码 src
http://www.cnblogs.com/linhaifeng/articles/5950339.html
仅仅补充一下
查看python 字符编码
import sys print(sys.getdefaultencoding())
查看window系统字符编码
linux
[xxxxxx@sso ~]$ echo $LANG zh_CN.UTF-8
最后加上大王的代码
import sys print(sys.getdefaultencoding()) msg = "我爱北京天安门" #msg_gb2312 = msg.decode("utf-8").encode("gb2312") msg_gb2312 = msg.encode("gb2312") #默认就是unicode,不用再decode,喜大普奔 gb2312_to_unicode = msg_gb2312.decode("gb2312") gb2312_to_utf8 = msg_gb2312.decode("gb2312").encode("utf-8") print(msg) print(msg_gb2312) print(gb2312_to_unicode) print(gb2312_to_utf8)
标签:blog strong www alt size img 分享 代码 src
原文地址:http://www.cnblogs.com/fengdao/p/6010114.html