题解 | #统计字符#
统计字符
https://www.nowcoder.com/practice/539054b4c33b4776bc350155f7abd8f5
#print(ord('a'),ord('z'),ord('A'),ord('Z'),ord(' '),ord('0'),ord('9')) while True: try: string=str(input()) English=0 blank=0 number=0 other=0 for i in string: if 65<=ord(i)<=90 or 97<=ord(i)<=122: English += 1 elif ord(i)==32: blank += 1 elif 48<=ord(i)<=57: number += 1 else: other += 1 print(English) # print(English,'\n',blank,'\n',number,'\n',other) 报错:格式不一致? print(blank) print(number) print(other) except: break