tuple to string?

Peter Hansen peter at engcorp.com
Fri Jul 22 09:08:25 EDT 2005


Francois De Serres wrote:
> hiho,
> 
> what's the clean way to translate the tuple (0x73, 0x70, 0x61, 0x6D) to 
> the string 'spam'?

 >>> mytuple = (0x73, 0x70, 0x61, 0x6D)
 >>> ''.join(chr(v) for v in mytuple)
'spam'




More information about the Python-list mailing list