newbie string conversion question
Duncan Booth
duncan.booth at invalid.invalid
Sat Apr 1 10:17:26 EST 2006
More information about the Python-list mailing list
Sat Apr 1 10:17:26 EST 2006
- Previous message (by thread): newbie string conversion question
- Next message (by thread): trouble with mxODBC, unixODBC and MSSQL
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Felipe Almeida Lessa wrote: >>>> a = "1234567890" >>>> b = [] >>>> for i in range(len(a)/2): > ... b.append(chr(int(a[i*2:i*2+2][::-1], 16))) > ... >>>> b = ''.join(b) >>>> print b > !Ce� >>>> print repr(b) > '!Ce\x87\t' Alternatively: >>> s = "1234567890" >>> ''.join(chr(int(b+a,16)) for a,b in zip(s[::2],s[1::2])) '!Ce\x87\t'
- Previous message (by thread): newbie string conversion question
- Next message (by thread): trouble with mxODBC, unixODBC and MSSQL
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
More information about the Python-list mailing list