s="123 abc [email protected]# ^&*"
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
原文地址:https://www.cnblogs.com/luo25236240/p/9255421.html
时间: 2024-12-19 10:58:16