https://img-mid.csdnimg.cn/release/static/image/mid/ask/901443243466133.jpg
s=input('请输入一行字符串:')
b,l,n=0,0,0
for c in s:
if c.islower():
l+=1
elif c.isupper():
b+=1
elif c.isdigit():
n+=1
print("大写字母个数%d,小写字符个数%d,数字个数%d"%(b,l,n))
代码如下:
s=input()
bg =0
sm =0
nmb =0
for c in s:
if 'a'<=c<='z':
sm+=1
elif 'A'<=c<='Z':
bg+=1
elif '0'<=c<='9':
nmb+=1
print(bg,',',sm,',',nmb,sep='')
import re
str = input("请输入一个字符串:")
big = len(re.compile(r"[A-Z]").findall(str))
small = len(re.compile(r"[a-z]").findall(str))
number = len(re.compile(r"[0-9]").findall(str))
print("大写字母个数{},小写字母个数{},数字个数{}".format(big, small, number), sep=",")
您好,我是有问必答小助手,您的问题已经有小伙伴帮您解答,感谢您对有问必答的支持与关注!