How do I convert characters into integers?
tenax.raccoon at gmail.com
tenax.raccoon at gmail.com
Thu Dec 16 10:52:33 EST 2004
There's another option that I haven't seen yet as well, where you use
the translation method for strings.
<code>
# Build a list where each entry is a character whose value is 3 higher
than its index.
charList = [ chr((x+3) % 256) for x in range(256) ]
transform = ''.join(charList) # Change the list to a string, which the
tranlate method requires
print "Hello there!".translate(transform)
</code>
The translate method can be very useful, although it can only translate
on a character-by-character basis.
--Jason
More information about the Python-list
mailing list