Categories
Python Answers

How to get the ASCII value of a character with Python?

Spread the love

Sometimes, we want to get the ASCII value of a character with Python.

In this article, we’ll look at how to get the ASCII value of a character with Python.

How to get the ASCII value of a character with Python?

To get the ASCII value of a character with Python, we can use the chr function.

For instance, we write:

c = chr(97)
print(c)

We call chr with the ASCII character code for ‘a’.

And then we assign the return character string to c.

Therefore, c is 'a'.

Conclusion

To get the ASCII value of a character with Python, we can use the chr function.

By John Au-Yeung

Web developer specializing in React, Vue, and front end development.

Leave a Reply

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