1. 字符串转 hex 字符串 字符串 >> 二进制 >> hex >> hex 字符串 import binasciidef str_to_hexStr(string): str_bin = string.encode('utf-8') return binascii.hexlify(str_bin).decode('utf-8') 2. hex 字符串转字符串 hex 字符串 >> hex >> 二进制 >> 字符串 import binasciidef hexStr_to_str(hex_str):hex = hex_str.encode('utf-8') str_bin = binascii.unhexlify(hex) return str_bin.decode('utf-8')
|