How to get an integer from a sequence of bytes

Mok-Kong Shen mok-kong.shen at t-online.de
Thu May 30 14:26:10 EDT 2013


Am 27.05.2013 17:30, schrieb Ned Batchelder:
> On 5/27/2013 10:45 AM, Mok-Kong Shen wrote:
>> From an int one can use to_bytes to get its individual bytes,
>> but how can one reconstruct the int from the sequence of bytes?
>>
> The next thing in the docs after int.to_bytes is int.from_bytes:
> http://docs.python.org/3.3/library/stdtypes.html#int.from_bytes

I am sorry to have overlooked that. But one thing I yet wonder is why
there is no direct possibilty of converting a byte to an int in [0,255],
i.e. with a constrct int(b), where b is a byte.

M. K. Shen




More information about the Python-list mailing list