import base64 name = "王大锤王大锤" # 编码: 字符串 -> 二进制 -> base64编码 b64_name = base64.b64encode(name.encode()) print(b64_name) # b'546L5aSn6ZSk' # 解码:base64编码 -> 二进制 -> 字符串 print(base64.b64decode(b64_name).decode())