How to Get the ASCII Value of a Character as an Int in Python

Created
Modified

Using ord Function

The ord() function returns an integer representing the Unicode code point of that character.

To get the ASCII code of a character, you can use the ord() function.

Here is an example code:

#!/usr/bin/python3

print(ord('a'))
print(ord('€'))

# inverse
print(chr(97))
97
8364
a

Related Tags

#get# #ascii# #char#