how to print out each single char from a string in HEX format?
Tue Jun 5 23:12:34 CEST 2007
> Great! It works.
There is a builtin function called hex() that does the same, but also shares
the same problem as the solution above:
This is probably not "nice" in your printouts, it doesn't allign.
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
More information about the Python-list