defstatisic(characters):a =0b =0c =0d =0#设置常量来储存各种字符数for i in characters:if i.isdigit():a +=1elif i.islower():b +=1elif i.isupper():c +=1else:d +=1#用循环来分别统计字符种类return a, b, c, d #返回统计数mes ="\nPlease enter some characters ,"
mes +=" and I will help you statisic it."print(mes)#给予提示
characters =input("the characters is: \n")#接受字符numbers,lower,upper,others = statisic(characters)#对接收到的字符进行统计result =(numbers,lower,upper,others)#化为元组print("结果是: ")print(f"\t数字有{
numbers}个。")print(f"\t大写字母有{
upper}个。")print(f"\t小写字母有{
lower}个。")print(f"\t其他字符有有{
others}个。")print(f"元组为{
result}")#输出各结果