import base64 # 想将字符串转编码成base64,要先将字符串转换成二进制数据 url = "hbSt~r`~a*+6~Q~x$*>~4x'jm.g+?" bytes_url = url.encode("utf-8") str_url = base64.b64encode(bytes_url) # 被编码的参数必须是二进制数据 print(str_url) # 将base64解码成字符串 import base64 url = "aGJTdH5yYH5hKis2FX5RfngkKj5+NAd4fydqbS5nKz8=" str_url = base64.b64decode(url).decode("utf-8") print(str_url)
base64的编码与解码
最新推荐文章于 2024-06-13 13:32:22 发布