python中使用base64库进行base64编码解码运算结果格式通常为b'xxxxx'
。
字串前的字母b表示bytes,该字符串为bytes类型。而python默认字符串是Unicode编码的,二者为不同类型。
使用如下方法可以将b'xxxx'
格式转化为普通字符串:
import base64
s = 'test'.encode('utf-8')
f = base64.b64encode(s)
print(f)
f = str(f, encoding = 'utf-8')
print(f)
运行结果为:
b'dGVzdA=='
dGVzdA==
这些文章讲的很清楚了:
https://www.cnblogs.com/liangmingshen/p/9274021.html
https://blog.csdn.net/gymaisyl/article/details/85109627