Help need with converting Hex string to IEEE format float

Peter Hansen peter at engcorp.com
Wed Dec 15 16:29:47 CET 2004


Christos TZOTZIOY Georgiou wrote:
> s = "".join(x).decode("hex")
> 
> I am not sure I remember in which version of Python the hex codec was
> added, but it is handy.

Of course, binascii could do this since 2.0 or so, but not
having to import another module *is* nice:

 >>> 'ff12'.decode('hex')
'\xff\x12'

 >>> import binascii
 >>> binascii.unhexlify('ff12')
'\xff\x12'

Thanks for pointing it out, Christos.



More information about the Python-list mailing list