Python ord()

In this post, we will see about Python ord() method.
Python ord() method returns integer representing the Unicode code point of character.It is inverse of function chr().


Syntax


Return

an integer representing the Unicode code point of character.
For example:
If you pass ‘A’, you will get 65 and if you pass ‘a’, you will get 97.


Example

Let’s see a very simple example:

print('integer representing the Unicode code point of character a:',ord('a')) print('integer representing the Unicode code point of that character A:',ord('A')) print('integer representing the Unicode code point of that character $:',ord('$'))

Output:

integer representing the Unicode code point of character a: 97
integer representing the Unicode code point of that character A: 65
integer representing the Unicode code point of that character $: 36

That’s all about Python ord() function.

Leave a Reply

Your email address will not be published. Required fields are marked *