Python base64 encoding and decoding

Python base64 encoding and decoding

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}")

Results of the
Insert picture description here

Guess you like

Origin blog.csdn.net/weixin_44102466/article/details/108691484