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.