Hi.

I have to open a binary file from an old computer and recover the
information stored (or at least try to). I use:

f=open('file.bin','rb')
a=f.read()
f.close()

a in now a string full of hex representations in the form:

a[6]='\x14'
a[7]='\x20'

I would like to convert these hex representations to int, but this
(the most obvious way) doesn't seem to be working

>>> q=a[6]
>>> q
'\x14'
>>> int(q,16)
Traceback (most recent call last):
  File "<stdin>", line 1, in ?
ValueError: invalid literal for int():
>>>

How can I do this?

Thanks
--
http://mail.python.org/mailman/listinfo/python-list

Reply via email to