python字符编码

断了今生、忘了曾经 提交于 2019-11-28 01:53:49

python3默认unicode

所以操作起来更加的方便,可以直接编码

msg = '你好,世界'

# python3
print(msg)
print(msg.encode('utf-8'))
print(msg.encode('euc-jp'))
print(msg.encode('utf-8').decode('utf-8').encode('gb2312'))

  

'''
python2

msg_gbk = msg.decode('utf-8).encode('gbk')
print(msg_gbk)

  

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!