On 2007-06-05, Troels Thomsen <nej> wrote: > with the printf inspired solution you can set the precision like this: > >>>> a = "12\n34" >>>> for c in a: > ... print "%#04x" % ord(c), > ... > 0x31 0x32 0x0a 0x33 0x34
And if you just want to do the conversion w/o printing: >>> a = "12\n34" >>> ' '.join(('%#04x' % ord(c) for c in a)) '0x31 0x32 0x0a 0x33 0x34' >>> ' '.join(('%02x' % ord(c) for c in a)) '31 32 0a 33 34' -- Grant Edwards grante Yow! Vote for ME -- I'm at well-tapered, half-cocked, visi.com ill-conceived and TAX-DEFERRED! -- http://mail.python.org/mailman/listinfo/python-list