Menu Close

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

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 ord function.

For instance, we write

n = ord('a')

to return the ASCII value of 'a' with ord.

Conclusion

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

Posted in Python, Python Answers