python的base64与hex相互转换"/>
python的base64与hex相互转换
以下代码为python3写法
import base64
import codecs
base64_text_dome="woidjw=="
hex_text_dome="c2889d8f"
# base64转化成Hex格式
hex_text = base64.b64decode(base64_text_dome).hex()
print(hex_text) #"hex_text=c2889d8f"
#Hex转化成 base64 格式
base64_text=codecs.encode(codecs.decode(hex_text_dome, 'hex'), 'base64').decode()
print(base64_text) #"base64_text=woidjw=="
python2写法参考:
[1048]python base64与hex相互转换_周小董-CSDN博客
更多推荐
python的base64与hex相互转换
发布评论