Matt Matt - 1 year ago 193
Python Question

ASCII value of a character in Python

How do I get the ASCII value of a character as an int in Python?

Answer Source

From here:

function ord() would get the int value of the char. And in case you want to convert back after playing with the number, function chr() does the trick.

>>> ord('a')
>>> chr(97)
>>> chr(ord('a') + 3)

There is also the unichr function, returning the Unicode character whose ordinal is the unichr argument:

>>> unichr(97)
>>> unichr(1234)
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download