bytes to string python base64

纯净搜索 为您找到 本页 3 条,用时 4.79 秒(数据源:360)

AI 回答 由 glm-4-flash 生成 · 仅供参考,请自行核实
1. 将bytes转换为base64编码的字符串:

import base64

bytes_data = b'Hello, World!'
base64_encoded_str = base64.b64encode(bytes_data).decode('utf-8')

2. 将base64编码的字符串解码回bytes:

base64_decoded_bytes = base64.b64decode(base64_encoded_str)

3. 将解码后的bytes转换为普通字符串:

decoded_str = decoded_bytes.decode('utf-8')