我的功能hex2int
如下:
import binascii
def hex2int(hexdata):
return [ord(c) for c in binascii.unhexlify(hexdata)]
它变成了一个字符串
'000000000000000000030c1a314a616d72614d331f0e0603010100000000000000010101010000010305060502000000021c4179b1dcedd2a76e41210e0906040403020202020100020825528dcdf2ffe0a86f3b22130c0a08060402000000000001010203020100000000000000000000000000000203030200000000020307142c5584a8bba37c4e28160c080603000000000000000001010101010101010101000000000000000d285c93c5dac7a06c4226160f0a0704030303030403030100000000000000000002030405040301000000000000000000000000000000000000000000000007111c2732404d5a61675f5342322118100d0a080604020100'
进入以下列表:
[0, 0, 0, 0, 0, 0, 0, 0, 0, 3, 12, 26, 49, 74, 97, 109, 114, 97, 77, 51, 31, 14, 6, 3, 1, 1, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 0, 0, 1, 3, 5, 6, 5, 2, 0, 0, 0, 2, 28, 65, 121, 177, 220, 237, 210, 167, 110, 65, 33, 14, 9, 6, 4, 4, 3, 2, 2, 2, 2, 1, 0, 2, 8, 37, 82, 141, 205, 242, 255, 224, 168, 111, 59, 34, 19, 12, 10, 8, 6, 4, 2, 0, 0, 0, 0, 0, 1, 1, 2, 3, 2, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 3, 3, 2, 0, 0, 0, 0, 2, 3, 7, 20, 44, 85, 132, 168, 187, 163, 124, 78, 40, 22, 12, 8, 6, 3, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 13, 40, 92, 147, 197, 218, 199, 160, 108, 66, 38, 22, 15, 10, 7, 4, 3, 3, 3, 3, 4, 3, 3, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 3, 4, 5, 4, 3, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 7, 17, 28, 39, 50, 64, 77, 90, 97, 103, 95, 83, 66, 50, 33, 24, 16, 13, 10, 8, 6, 4, 2, 1, 0]
我正在尝试编写int2hex
获取此列表并返回第一个字符串的反函数。
我目前有
def int2hex(intdata):
return binascii.hexlify(''.join([hex(i) for i in intdata]))
但这不会返回正确的结果。你能解释一下我哪里出错了吗?