How to get an integer from a sequence of bytes

Dave Angel davea at davea.name
Mon May 27 20:41:59 EDT 2013


On 05/27/2013 08:31 PM, Steven D'Aprano wrote:
> On Mon, 27 May 2013 11:30:18 -0400, Ned Batchelder wrote:
>
>> 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:
>
> And I can't believe I missed that too :-(
>
>
And that approach probably works for negative ints too.


-- 
DaveA



More information about the Python-list mailing list