首页 > 其他 > 详细

字符编码

时间:2016-10-29 11:54:06      阅读:222      评论:0      收藏:0      [点我收藏+]

我实在不想说什么了,这个写的太详细了明确了,跪了的感觉,大王完全不在了

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)

 

字符编码

原文:http://www.cnblogs.com/fengdao/p/6010114.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!