[Python] Re: doppio backslash non va

Nicola Larosa nico a tekNico.net
Dom 4 Feb 2007 18:57:48 CET


Daniele Zambelli wrote:
> se ho capito bene, la prima parte del tuo problema è trasformare la
> stringa:
> "03ff55a600"
> 
> nella stringa:
> "\x03\xff\x55\xa6\x00"

>>> s = '03ff55a600'
>>> ''.join([chr(int(t[0]+t[1], 16)) for t in zip(s[:-1:2], s[1::2])])
'\x03\xffU\xa6\x00'

>>> '\x55'
'U'


-- 
Nicola Larosa - http://www.tekNico.net/

Legally or otherwise, domestically or from overseas, flawless copies can
and will be obtained. And the modern European pirates who retrieve and
share our cultural gold - gold that the owners had forsaken - are not
scoundrels who defy the law but heroes who advance its ultimate aim.
 -- Peter Guttman, July 2006



Maggiori informazioni sulla lista Python