在Python3.2中添加了int.from_bytes(bytes, byteorder, *, signed=False)
可实现不固定长度的bytes类型数据转int类型数据
1 >>> int.from_bytes(b'\xfc\x00', byteorder='big', signed=True) ##signed标志是否为有符号数 2 -1024 3 >>> int.from_bytes(b'\xfc\x00', byteorder='big', signed=False) 4 64512 5 >>> int.from_bytes(b'\x00\x00\x00\x14', byteorder='big', signed=True) ##byteorder标志小字节顺序还是大字节顺序 6 20 7 >>> int.from_bytes(b'\x00\x00\x00\x14', byteorder='little', signed=True) 8 335544320