xor on strings
jason at jorendorff.com
Mon Feb 11 06:44:19 CET 2002
> >>> red = hex(56)[2:4]
> >>> green = hex(156)[2:4]
> >>> blue = hex(12)[2:4]
> >>> thestring = '&H' + blue + green + red
> but here, since the blue string is only 1 character it throws the
> rest off.
>>> colors = (56, 156, 12)
>>> print '&H%02x%02x%02x' % colors
If you would prefer to have a function instead,
you can use string.zfill().
## Jason Orendorff http://www.jorendorff.com/
More information about the Python-list