标签:空格 else other 文字 family for letter 输入 字母
s="123 abc !@# ^&*"
digit_num=0
letter_num=0
space_num=0
other_num=0
for i in s:
if i.isalpha():
letter_num+=1
elif i.isdigit():
digit_num+=1
elif i.isspace():
space_num+=1
else:
other_num+=1
print u"共有字母:",letter_num
print u"共有数字:",digit_num
print u"共有空格:",space_num
12.输入一行字符,分别统计出其中英文字母、空格、数字和其它字符的个数
标签:空格 else other 文字 family for letter 输入 字母
原文地址:https://www.cnblogs.com/luo25236240/p/9255421.html