📜  字符 python 代码示例

📅  最后修改于: 2022-03-11 14:45:05.640000             🧑  作者: Mango

代码示例1
#check if a is uppercase,lowercase,other character or digits
a=int(input('enter'))
if chr(a)>'A' and chr(a)<'Z' : #here 'A' is 65 and 'Z' is 91
        print('upper case',a,'and ascii code',chr(a))
elif chr(a)>'a' and chr(a)<'z' : # here 'a' is 97 and 'z' is 122
        print('lower case',a, 'and ascii code is',chr(a))
elif chr(a)>'0' and chr(a)<'9' :# here '0' is 48 and '9' is 57
        print('digits',a,'and ascii code is',chr(a))
else:
        print('other special',a,'andcharacter ascii code ',chr(a))