ASCII ((American Standard Code for Information Interchange): 美國信息交換標准代碼)是基於拉丁字母的一套電腦編碼系統,主要用於顯示現代英語和其他西歐語言。它是最通用的信息交換標准,並等同於國際標准ISO/IEC 646。
在python中,經常要用到它和字符的相互轉換,這里做了一個例子,僅供參考:
1 c = input("Please input a char: ") 2 a = int(input("Please input a ascii:")) 3 while True: 4 if a < 0: 5 print("ascii is wrong, Plese try again") 6 a = int(input("Please input a ascii:")) 7 elif a > 1000: 8 print("ascii is wrong, Plese try again") 9 a = int(input("Please input a ascii:")) 10 else: 11 break 12 13 print(" this is a ascii test") 14 print("assic is:",ord(c)) 15 print(" char is:", chr(a))
參考路徑:
1 https://www.runoob.com/python3/python3-ascii-character.html