Python ord() Built in Function

The ord() function is used to get the integer value that represents the Unicode code point of a character. The syntax of the ord() function is:

ord(char)

The char parameter is a string of length one that contains a Unicode character. The return value is an integer between 0 and 1114111 (inclusive). Some common Unicode code points are:

48 for ‘0’
65 for ‘A’
97 for ‘a’
8364 for ‘€’

Here are some examples of using the ord() function in Python:

To get the Unicode code point of an integer character:

print(ord('8')) # prints 48

To get the Unicode code point of an alphabet character:

print(ord('R')) # prints 82

To get the Unicode code point of a special character:

print(ord('&')) # prints 38

To get the Unicode code point of a non-ASCII character:

print(ord('€')) # prints 8364 

If you have any questions about this code, you can drop a line in comment.

Comments

Popular posts from this blog

Python chr() Built in Function

Stock Market Predictions with LSTM in Python

Collections In Python

Python Count Occurrence Of Elements

Python One Liner Functions