1、输入字符串,分别字符串中含有数字、字母、空格和其它字符个数。
def findstr(*param):
chars = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ'
nums = '0123456789'
space = ' '
count_char = 0
count_num = 0
count_sp = 0
count_sym = 0
for i in x:
if i in chars:
count_char += 1
elif i in nums:
count_num += 1
elif i == space:
count_sp += 1
else:
count_sym +=1
print("有英文字母%d个,数字%d个,空格%d个,其它字符%d个"%