python快速算大小写字母与数字个数

def count(Zifu):
    number1 = 0
    number2 = 0
    number3 = 0
    for i in Zifu:
        if i.isupper():
            number1 =number1 +1
        elif i.islower():
            number2  = number2 +1
        elif i.isnumeric():
            number3  = number3 +1
    return {"大写字母":number1,"小写字母":number2,"数字":number3}
print(count("sasadsfg49809rstgjkh"))

你可能感兴趣的:(python,python)