literal hex value to bin file.
Fri Oct 8 07:07:51 CEST 2004
yaipa at yahoo.com (yaipa h.) writes:
> I seemed to have worked it out. The bit of code below will write
> the actual hex string literal to a binary file as is. What I kept
> getting was the hexascii representation of the hex string, so that
> '9' would write to file as 0x39 and 'a' would write to the file as
> 0x61. What I wanted was '9' to write to the file as 0x09 and '7f' to
> write out as 0x7f.
Oh I see. Normally you'd use the chr function:
i = int('7f', 16)
More information about the Python-list