python3.5.2中文字符乱码问题解决

 

>>> str = "世界你好!"
>>> b = str.encode('utf-8')
>>> type(b)
<class 'bytes'>
>>> b
b'\xe4\xb8\x96\xe7\x95\x8c\xe4\xbd\xa0\xe5\xa5\xbd!'
>>> b.decode('utf-8')
'世界你好!'

  



posted @ 2017-06-30 16:52  tec2019  阅读(153)  评论(0编辑  收藏  举报