python字符编码

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)

  

posted @ 2019-08-21 01:25  jack-kaller  阅读(189)  评论(0编辑  收藏  举报