Python – Get the Unicode code of any character

In this post we’ll be creating a Python script that will retrieve the Unicode code of a character as an integer.

To achieve this we use the ‘ord()’ function, see the example below for how this is done.

#Returns 97

#Returns 98

Similarly we can inverse this and convert a Unicode code back in to a character. To do this we would use the ‘chr()’ function as seen below.

#Returns a

#Returns b

Leave a Reply