python之base64编码解码

python之base64编码解码

import base64


s = "hello fer"
# base64编码
base64_str = base64.b64encode(s.encode()).decode("utf-8")
print(f"base64编码后字符串:  {base64_str}")
# base64解码
res_str = base64.b64decode(base64_str).decode("utf-8")
print(f"base64解码后数据:   {res_str}")

执行结果
在这里插入图片描述

猜你喜欢

转载自blog.csdn.net/weixin_44102466/article/details/108691484