The Python ord() function
Description
The ord() function is the counterpart of chr() (for 8-bit ASCII strings) or unichr() (for Unicode objects). It takes a character (a string of length 1) as an argument and returns the corresponding ASCII or Unicode value. If the given Unicode character is outside the range defined by your Python build, a TypeError is raised.
Syntax
The following is the syntax of the ord() method:
ord(c)
Parameters
- c -- a character.
Return Value
The return value is the corresponding decimal integer.
Example
The following examples demonstrate the use of the ord() method:
ord
(
'
a
'
)
97
ord
(
'
b
'
)
98
ord
(
'
c
'
)
99
Python built-in function