在Python中使用ubinasciia2b_base64()函数将Base64字符串转换为字节数据
发布时间:2023-12-13 07:52:50
在Python中可以使用base64.b64decode()函数将Base64字符串转换为字节数据。
下面是一个使用例子:
import base64 base64_string = "SGVsbG8gd29ybGQh" byte_data = base64.b64decode(base64_string) # 打印字节数据 print(byte_data)
输出:
b'Hello world!'
在上面的例子中,我们使用base64.b64decode()函数将Base64字符串"SGVsbG8gd29ybGQh"转换为字节数据b'Hello world!'。
可以通过print()函数将字节数据打印出来。
注意:在Python 3中,base64.b64decode()函数返回的是字节数据类型(bytes),而不是字符串类型。
