Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Python ASCII码与字符相互转换 #6

Open
Lucifer-ww opened this issue May 19, 2020 · 0 comments
Open

Python ASCII码与字符相互转换 #6

Lucifer-ww opened this issue May 19, 2020 · 0 comments
Labels

Comments

@Lucifer-ww
Copy link
Owner

:octocat:以下代码用于实现ASCII码与字符相互转换:(来自菜鸟教程)

# Filename : test.py
# author by : www.runoob.com
 
# 用户输入字符
c = input("请输入一个字符: ")
 
# 用户输入ASCII码,并将输入的数字转为整型
a = int(input("请输入一个ASCII码: "))
 
 
print( c + " 的ASCII 码为", ord(c))
print( a , " 对应的字符为", chr(a))

输入与输出

python3 test.py 
请输入一个字符: a
请输入一个ASCII码: 101
a 的ASCII 码为 97
101  对应的字符为 e
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant