Python ord() Function
Python ord() Function
The ord() function in Python returns the number representing the Unicode code of a specified character.
Syntax
ord(c)
Parameter
c: This parameter represents a string or any character.
Return
This function returns the number representing the Unicode code of a specified character.
Example 1
# Python program explaining # the ord() function str_val= "r" ord_val = ord(str_val) print(ord_val)
Output
114
Example 2
# Python program explaining # the ord() function ord_val = ord("R") # writing in character gives the same result ord_val1 = ord('R') print(ord_val, ord_val1)
Output
82 82