str = 'LiKeYou960415'
cl = 0 #计数大写字母个数
lc = 0 #计数小写字母个数
num = 0 #计数数字个数
i = 0 #遍历字符串中所有的元素
while i < len(str): #判断是否遍历完毕,len()是统计字符串的字长
if str[i].isupper(): #判断当前是否是大写字母
cl += 1 #计数
elif str[i].islower(): #判断是否是小写字母
lc += 1 #计数
elif str[i].isdigit(): #判断当前是否是数字
num += 1 #计数
i += 1 #遍历字符串
print('大写:', cl)
print('小写:', lc)
print('数字:', num)

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-12-17
  • 2022-03-08
  • 2022-12-23
  • 2022-12-23
  • 2021-11-18
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-02-10
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案