String to ASCII values

Dave Kuhlman dkuhlman at rexx.com
Thu Oct 9 11:40:04 EDT 2003


Benjamin Hepp wrote:

> Hello,
> 
> How do I convert a string like 'A' to its ASCII value(s) ?

Perhaps you want something like this:

    >>> for x in 'abcde':
    ...   print ord(x), hex(ord(x))
    ...
    97 0x61
    98 0x62
    99 0x63
    100 0x64
    101 0x65

Look here for documentation:

    http://www.python.org/doc/current/lib/built-in-funcs.html


Dave

-- 
Dave Kuhlman
http://www.rexx.com/~dkuhlman
dkuhlman at rexx.com




More information about the Python-list mailing list