data conversion question (binary string to 'real string')
manish.j at gmx.net
Fri Jul 25 15:35:01 CEST 2003
Alexander Eisenhuth wrote:
> This two lines converts 0.5 to a string in binary
> >>>from struct import *
from binascii import hexlify
> >>>bin_str = pack('!f', 0.5)
> now bin_str is '?\x00\x00\x00', wich is the representation
> of 0.5 in the memory. I need now to convert this binary
> string to "3F000000", where '3F' is the hex value of the '?'
> in ascii - table.
> Any ideas ??
foo = hexlify(bin_str)
PS: You posted the same message thrice, by mistake.
Manish Jethani (manish.j at gmx.net)
phone (work) +91-80-51073488
More information about the Python-list