The ord () function in Python
The built-in ord () function in Python returns an integer representing the Unicode code of the specified character.
Python's ord () function syntax
ord(c)
The ord () function is the reciprocal of the function chr ().
The parameter of ord () function
ord () has a unique parameter:
c
: is any string, any character.
Value returned from ord ()
Ord () returns an integer representing the Unicode code of the specified character.
For example
# số nguyên print(ord('5')) # chữ cái print(ord('A')) # ký tự print(ord('$'))
Run the program, the result is:
53 65 36
See also: Built-in Python functions
4 ★ | 1 Vote
You should read it
May be interested
- The input () function in Pythonpython's built-in input () function allows users to enter data, convert it into a string, and return the entered content.
- Type () function in Pythonthe built-in function type () in python returns the type of object passed as parameter.
- Print () function in Pythonthe print () function in python works to display the screen magic when the program executes.
- Sum () function in Pythonthe built-in function sum () in python returns the sum of all numbers in iterable.
- __Import __ () function in Python__import __ () is an advanced function called by the import statement in python
- The function hasattr () in Pythonthe hasattr () function in python is used to check if the input object has the property you want to find.