#题目:输入一行字符,分别统计出其中英文字母、空格、数字和其它字符的个数。 s = input('请输入字符串:') alf = 0 space = 0 digi = 0 other = 0 for i in s: if i.isalpha(): alf += 1 elif i.isspace(): space += 1 elif i.isdigit(): digi += 1 else: other += 1 print ('alf = %s'% alf,'space = %s'% space ,'digi = %s'% digi, 'other = %s'%other)