python关于解码的问题

decode:把一种编码转换成 unicode —> 解码

# byte -> str
>>> a =b'hello'
>>> a
b'hello'
>>> a.decode('utf-8')
'hello'
>>> 

encode:把unicode转换成另一种编码 —> 编码

# str -> byte
>>> a = 'hello'
>>> a
'hello'
>>> a.encode('utf-8')
b'hello'
    原文作者:南方老F
    原文地址: https://www.jianshu.com/p/2a3461897dca
    本文转自网络文章,转载此文章仅为分享知识,如有侵权,请联系博主进行删除。
点赞