Python ASCII Code and Character Conversion
The following code is used to convert between ASCII codes and characters:
Example (Python 3.0+)
# Filename : test.py
# author by : www.example.com
# User inputs a character
c = input("Please enter a character:")
# User inputs an ASCII code, and converts the input number to an integer
a = int(input("Please enter an ASCII code:"))
print( c + "The ASCII code of", ord(c))
print( a , "The corresponding character is", chr(a))
The output result of executing the above code is:
python3 test.py 请输入一个字符: a 请输入一个ASCII码: 101 a 的ASCII 码为 97 101 对应的字符为 eOther Extensions
Python3 Examples