a = str(input())
smallword = 0
bigword = 0
number = 0
blank = 0
others = 0
longth = len(a) #记录字符串的长度,后面用于遍历次数
#i作为字符串中的具体字符参加遍历
for i in a:
#若i在‘abcdefghijklmnopqrstuvwxyz’里面则小写字母加1
if i in 'abcdefghijklmnopqrstuvwxyz' :
smallword = smallword + 1
if i in 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' :
bigword = bigword + 1
if i in ' ':
blank = blank + 1
others = longth - smallword -bigword - blank
print(' 小写字母 :',smallword,' 大写字母 :',bigword,' 空格键 :',blank,' 其它字符: ',others)

本文介绍了一种使用Python编程语言统计字符串中小写字母、大写字母、空格及其他字符数量的方法。通过遍历字符串并检查每个字符来实现计数。
4095

被折叠的 条评论
为什么被折叠?



