当前位置: 首页> 打印机> 正文

支持代5b00

def Count():

str1=input(‘请输入一个字符串:’)

letter=0 #英文字母

space=0 #空格

digit=0 #数字

other=0 #其他字符

for i in str1:

if(i>=’a’ and i<='z') or (i>=’A’ and i<='Z'):

letter+=1

elif(i==' '):

space+=1

elif(i>=’0′ and i<='9'):

digit+=1

else:

other+=1

print('字母',letter,'个,数字',digit,'个,空格',space,'个,其他字符',other,'个')

Count()

最新文章