EN
Python - convert character to ASCII code
0 points
In this article, we would like to show you how to convert characters to ASCII code in Python.
Quick solution:
xxxxxxxxxx
1
character = 'a'
2
unicode = ord(character)
3
4
print(unicode) # 97
In this example, we use ord()
function to return the number representing the ASCII code of a specified character.
xxxxxxxxxx
1
character = 'a'
2
unicode = ord(character)
3
4
print(unicode) # 97
Output:
xxxxxxxxxx
1
97