List of integers

Terry Reedy tjreedy at udel.edu
Mon Dec 14 04:56:06 EST 2015


On 12/13/2015 7:24 PM, KP wrote:
>
>
> data = list(f.read(4))
> print data
>
> from a binary file might give

In 2.x, a binary file and a text file are not distinguished.

> ['\x10', '\x20', '\x12', '\x01']

If a 'binary' file yields strings, you must be using 2.x.

> How can I receive this instead?
> [0x10, 0x20, 0x12, 0x01]

Use python 3.

-- 
Terry Jan Reedy




More information about the Python-list mailing list