Python - How to convert character to ASCII

By xngo on June 12, 2019

Converting character to ASCII and back is quite easy. Simply use chr() and ord() functions. Here are some examples.

# Convert ASCII to character.
print(chr(65))
 
# Convert ASCII to character.
print(ord('A'))

Output

A
65

About the author

Xuan Ngo is the founder of OpenWritings.net. He currently lives in Montreal, Canada. He loves to write about programming and open source subjects.