Question about binary file reading
John Machin
sjmachin at lexicon.net
Wed Mar 4 20:25:21 EST 2009
On Mar 5, 12:13 pm, Benjamin Peterson <benja... at python.org> wrote:
> Tino Wildenhain <tino <at> wildenhain.de> writes:
>
> > Rhodri James wrote:
> > > for b in x:
> > > print hex(ord(b))
>
> > better:
>
> > print x.encode("hex")
>
> even better:
>
> import binascii
> print binascii.hexlify(some_bytes)
AFAICT binascii.hexlify(some_bytes) gives the SAME result as
some_bytes.encode("hex") for much more typing -- I see no "better"
here.
More information about the Python-list
mailing list