Hexadecimal list conversion
Andreas Tawn
andreas.tawn at ubisoft.com
Thu Dec 20 08:00:59 EST 2007
> Hi All.
>
> I have a list which is a line from a file:
> ['\x003\x008\x001\x004\x007\x005\x00.\x005\x000\x002\x005\x009
> \x009\x00',
> '\x002\x001\x003\x006\x002\x002\x00.\x001\x007\x004\x002\x008\
> x002\x00']
>
> This should be in the format:
> ['381475.502599', '213622.174282']
>
> I've tried a few options using replace (replacing "\x00" with "") and
> trying to convert from hexademical to decimal.
>
> But nothing has worked. Can anybody give any tips to help?
>
> Thanks.
Somthing like:
line =
['\x003\x008\x001\x004\x007\x005\x00.\x005\x000\x002\x005\x009\x009\x00'
,
'\x002\x001\x003\x006\x002\x002\x00.\x001\x007\x004\x002\x008\x002\x00']
result = [''.join(x.split('\x00')) for x in line]
Cheers,
Drea
More information about the Python-list
mailing list