在Python 3.2中,如何将十六进制字符串转换为有符号整数?
我能想出的最好办法就是
h = '9DA92DAB'
b = bytes(h, 'utf-8')
ba = binascii.a2b_hex(b)
print(int.from_bytes(ba, byteorder='big', signed=True))
有没有更简单的方法?Unsigned要简单得多:int(h,16)
顺便说一句,这个问题的起源是itunes persistent id - music library xml version and iTunes hex version