| 
 | 
 
马上注册,结交更多好友,享用更多功能^_^
您需要 登录 才可以下载或查看,没有账号?立即注册  
 
x
 
def count(*param): 
    length = len(param) 
    for i in range(length): 
        letters = 0 
        space = 0 
        digit = 0 
        others = 0 
        for each in param[i]: 
            if each.isalpha(): 
                letters += 1 
            elif each.isdigit(): 
                digit += 1 
            elif each.isdigit(): 
                digit += 1 
            elif each == " ": 
                space += 1 
            else: 
                others += 1 
        print("第%d个字符串共有 : 英文字母 %d个,空格 %d个,其他字符 %d 个。"%(i+1,letters,digit,space,others) ) 
 
 
 
 
 
 
count("i love fishc.com.","i love you, you love me.") 
Traceback (most recent call last): 
  File "<pyshell#17>", line 1, in <module> 
    count("i love fishc.com.","i love you, you love me.") 
  File "C:/Users/麦家报/AppData/Local/Programs/Python/Python37/2.3.py", line 19, in count 
    print("第%d个字符串共有 : 英文字母 %d个,空格 %d个,其他字符 %d 个。"%(i+1,letters,digit,space,others) ) 
TypeError: not all arguments converted during string formatting
 |   
 
 
 
 |