Weird list conversion

Ian Kelly ian.g.kelly at gmail.com
Sun Dec 13 14:59:25 EST 2015


On Sun, Dec 13, 2015 at 12:45 PM,  <high5storage at gmail.com> wrote:
> Hi all,
>
>       f = open("stairs.bin", "rb")
>       data = list(f.read(16))
>       print data
>
> returns
>
> ['=', '\x04', '\x00', '\x05', '\x00', '\x01', '\x00', '\x00', '\x00', '\x00', '\x00', '\x00', '\x00', '\x00', '\x00', '\x00']
>
> The first byte of the file is 0x3D according to my hex editor, so why does Python return '=' and not '\x3D'?

They're equivalent representations of the same thing.

py> '\x3D'
'='



More information about the Python-list mailing list