ord

Full name
ord
Library
Built-in
Syntax

ord(c)

Description

The ord function returns the Unicode code of the character passed as an argument.

Unicode character list

This function is the inverse of the chr function.

Parameters
  • c: character whose Unicode code we want to know
Examples

In this example we obtained the Unicode code of different characters:

print(ord("a"))
print(ord("A"))
print(ord("ñ"))
print(ord("€"))

Ord function Example of use

 

The argument must be a single character. If it is a text string of a greater length, the function returns an error of type TypeError:

print(ord("ab"))

Ord function Example of use

 

The same happens if the text string included as an argument has zero length:

print(ord(""))

Ord function Example of use

 

Submitted by admin on Sun, 01/20/2019 - 15:20