数字和字母太多加上特殊符号不好统计怎么办几行代码帮你解决
Str=input('请输入一段字符:',)
char=0
space=0
num=0
other=0
for i in Str:
if ((i>'A' and i<'Z') or (i>'a' and i<'z')): #查找字母
char=char+1 #char+=1 字母个数累加
elif (i==' '): #查找空格
space=space+1
elif (i>='0' and i<='9'): #查找数字
num=num+1
else: #查找其他
other=other+1