def str_to_hex(self,s):
# 文本转16进制
return ' '.join([hex(ord(c)).replace('0x', '') for c in s])
def hex_to_str(self,s):
#16进制转为文本
return ''.join([chr(i) for i in [int(b, 16) for b in s.split(' ')]])
def str_to_hex(self,s):
# 文本转16进制
return ' '.join([hex(ord(c)).replace('0x', '') for c in s])
def hex_to_str(self,s):
#16进制转为文本
return ''.join([chr(i) for i in [int(b, 16) for b in s.split(' ')]])
本文标题:Python 字符串和16进制的相互转换
本文链接:https://www.haomeiwen.com/subject/usuydrtx.html
网友评论