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():
扫描二维码关注公众号,回复:
1837835 查看本文章
![](/qrcode.jpg)
space_num+=1
else:
other_num+=1
print u"共有字母:",letter_num
print u"共有数字:",digit_num
print u"共有空格:",space_num