1 # 分别统计字符串参数(可能不止一个参数)中的数字、字母、空格和其他字符 2 def count(*argu): 3 length = len(argu) 4 for i in range(length): 5 number, letter, space, other = 0, 0, 0, 0 6 for each in argu[i]: 7 if each.isalpha(): 8 letter += 1 9 elif each.isdigit(): 10 number += 1 11 elif each == " ": 12 space += 1 13 else: 14 other += 1 15 print('第%d个字符串*有:%d个字母,%d个数字,%d个空格,%d个其他字符' % (i + 1, letter, number, space, other)) 16 17 18 count("We love each other deeply!", "I love you, you love me 2.")