data conversion question (binary string to 'real string')
Alexander Eisenhuth
stacom at stacom-software.de
Fri Jul 25 10:08:45 EDT 2003
Manish Jethani wrote:
> Alexander Eisenhuth wrote:
>
>
>>This two lines converts 0.5 to a string in binary
>>representation
>>
>> >>>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)
> print foo
>
> -Manish
>
> PS: You posted the same message thrice, by mistake.
>
Thanks, that's it
More information about the Python-list
mailing list