Rohit wrote:
> As part of a proprietary socket based protocol I have to convert a
> string of length 10,
>
> say, "1234567890"
>
> to send it as 5 characters such that their hex values are
>
> 0x21 0x43 0x65 0x87 0x09
>
> (Hex value of each character is got by transposing two digit
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
Em Sáb, 2006-04-01 às 06:17 -0800, Rohit escreveu:
> As part of a proprietary socket based protocol I have to convert a
> string of length 10,
>
> say, "1234567890"
>
> to send it as 5 characters such that their hex values are
>
> 0x21 0x43 0x65 0x87 0x09
>
> (Hex value of each cha
As part of a proprietary socket based protocol I have to convert a
string of length 10,
say, "1234567890"
to send it as 5 characters such that their hex values are
0x21 0x43 0x65 0x87 0x09
(Hex value of each character is got by transposing two digits at a
time)
How can I do t