如何将一个长的无符号整型转换为十六进制的四个字节的列表?
例如。
777007543 = 0x2E 0x50 0x31 0xB7
发布于 2011-01-04 22:59:43
使用struct module
In [6]: import struct
In [14]: map(hex,struct.unpack('>4B',struct.pack('>L',777007543)))
Out[14]: ['0x2e', '0x50', '0x31', '0xb7']或者,如果大写很重要,
In [17]: map('0x{0:X}'.format,struct.unpack('>4B',struct.pack('>L',777007543)))
Out[17]: ['0x2E', '0x50', '0x31', '0xB7']https://stackoverflow.com/questions/4594899
复制相似问题