6.10 使用base64对二进制数据进行编码和解码
- b64encode 函数对二进制进行编码
- .decode('ascii')函数来解码Unicode
>>> s = b'hello'
>>> import base64
>>> a =base64.b64encode(s)
>>> a
b'aGVsbG8='
>>> base64.b64decode(a)
b'hello'
>>> base64.b64decode(a).decode('ascii')
'hello'
>>>
>>> s = b'hello'
>>> import base64
>>> a =base64.b64encode(s)
>>> a
b'aGVsbG8='
>>> base64.b64decode(a)
b'hello'
>>> base64.b64decode(a).decode('ascii')
'hello'
>>>
本文标题:python Base64编码和解码
本文链接:https://www.haomeiwen.com/subject/typdprtx.html
网友评论