Reading a binary file
Sorin Marti
mas at semafor.ch
Thu Jun 26 05:33:20 EDT 2003
Hi Andrew,
Thanks for your answer!
Andrew Bennetts wrote:
> On Thu, Jun 26, 2003 at 10:01:06AM +0200, Sorin Marti wrote:
>
>>But now I need the hex values of the binary file.
>
> You can get the hex value of a 1-character string with hex(ord(char)), e.g.:
>
> >>> char = 'a'
> >>> hex(ord(char))
> '0x61'
>
That is not exactly what I meant. I've found a solution (a is the binary
data):
b = binascii.hexlify(a)
For example it gives me C8 which is a HEX-Value. How to change this one
into a decimal? (The decimal should be 130, right?)
Thanks in advance
Sorin
More information about the Python-list
mailing list