ord()
Introduction
ord(c, /) Given a string representing one Unicode character, return an integer representing the Unicode code point of that character. For example, ord('a') returns the integer 97 and ord('€') (Euro sign) returns 8364. This is the inverse of chr().
The function ord() takes a character and returns its ordinal number in Unicode
Takes str returns int
Syntax
ord(character)
Example
The simplest example
print("\t", ord("\t")) print("\n", ord("\n")) print("\r", ord("\r")) print(" ", ord(" ")) print("0 ", ord("0")) print("A ", ord("A")) print("B ", ord("B")) print("\ ", ord("\"))
\t 9 \n 10 \r 13 32 0 48 A 65 B 66 \ 92
Article author: Andrei Olegovich