python学习笔记

1 字符编码

>>> a= u"你好"
>>> b = a.encode('unicode_escape')
>>> b
b'\\u4f60\\u597d'
>>> c = b.decode('unicode_escape')
>>> c
'你好'
>>> a = "你好"
>>> b = a.encode('utf-8')
>>> b
b'\xe4\xbd\xa0\xe5\xa5\xbd'
>>> 

 

posted @ 2017-09-29 17:30  云淡风轻~  阅读(124)  评论(0编辑  收藏  举报