# 编写一个函数,分别统计出传入字符串参数(可能不止一个参数)的英文字母、数字、空格和其他字符的个数
def str_count(*args):
length = len(args)
for i in range(length):
digit = 0
letters = 0
space = 0
others = 0
for each in args[i]:
if each.isalpha():
letters += 1
elif each.isdigit():
digit += 1
elif each.isspace():
space += 1
else:
others += 1
print(‘第%d个字符串共有%d个字母,共有%d个数字,共有%d个空格,共有%d个其他字符‘ % (i + 1, letters, digit, space, others))
str_count(‘I love my baby 126.com!‘, ‘today very happy 0330@‘)
原文:https://www.cnblogs.com/laosun0204/p/14595609.html