classmethod int.from_bytes(bytes, byteorder, *, signed=False)
Return the integer represented by the given array of bytes.
>>> int.from_bytes(b'\x00\x10', byteorder='big') 16 >>> int.from_bytes(b'\x00\x10', byteorder='little') 4096 >>> int.from_bytes(b'\xfc\x00', byteorder='big', signed=True) -1024 >>> int.from_bytes(b'\xfc\x00', byteorder='big', signed=False) 64512 >>> int.from_bytes([255, 0, 0], byteorder='big') 16711680
The argument bytes must either be a bytes-like object or an iterable producing bytes.
The byteorder argument determines the byte order used to represent the integer. If byteorder is "big"
, the most significant byte is at the beginning of the byte array. If byteorder is "little"
, the most significant byte is at the end of the byte array. To request the native byte order of the host system, use sys.byteorder
as the byte order value.
The signed argument indicates whether two’s complement is used to represent the integer.
New in version 3.2.
Please login to continue.