#代码
ch=input("请输入一个字符:")
print(ch,"的ASCII码为:",ord(ch))
#运行结果
F:\TestPython\venv\Scripts\python.exe F:/TestPython/demo1.py
请输入一个字符:A
A 的ASCII码为: 65
Process finished with exit code 0
#代码
ch=input("请输入对应的ASCII码:")
ch=int(ch) #以字符串的形式接收键盘输入的内容,所以要对其进行转换
print(ch,"的ASCII码为:",chr(ch))
#运行结果
F:\TestPython\venv\Scripts\python.exe F:/TestPython/demo1.py
请输入对应的ASCII码:99
99 的ASCII码为: c
Process finished with exit code 0