python int.from_bytesでバイトから整数に a = 128 print(a.to_bytes(2, 'big')) print(a.to_bytes(4, 'big')) print(int.from_bytes(b'\x00\x80', 'big')) print(int.from_bytes(b'\x00\x00\x00\x80', 'big'))