美文网首页
python Base64编码和解码

python Base64编码和解码

作者: 孙广宁 | 来源:发表于2022-05-23 23:27 被阅读0次
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'
>>>

相关文章

网友评论

      本文标题:python Base64编码和解码

      本文链接:https://www.haomeiwen.com/subject/typdprtx.html