Skip to main content

ord()

The ord() function in Python is a built-in function that returns the Unicode code point of a character passed as an argument. It is used to convert a single character into its integer Unicode code value.

Parameter Values

Parameter Description
c

A character (string of length 1) whose Unicode code point value is to be retrieved.

Return Values

The ord() function returns an integer representing a Unicode character.

How to Use ord() in Python

Example 1:

Returns an integer representing the Unicode code point of the given character

ord('A')
Example 2:

For non-ASCII characters, ord() can handle Unicode characters as well

ord('€')
Example 3:

Accepts a string of length 1 as an argument and returns the Unicode code point of the first character

ord('😊')