How do I convert characters into integers?

Scott David Daniels Scott.Daniels at Acm.Org
Thu Dec 16 02:09:07 CET 2004

Markus Zeindl wrote:
> Hello,
> I want to write a simple encrypter, but I've got a problem:
> How can I convert characters into integers?....

Check this out, you'll like it even more than ord/chr:
     import array

     def mangle(message):
         a = array.array('B')
         for i in range(len(a)):
             a[i] += 1
         return a.tostring()

     print mangle('Hello, Harry')

-Scott David Daniels
Scott.Daniels at Acm.Org

More information about the Python-list mailing list