题解 | #参数解析#

统计大写字母个数

http://www.nowcoder.com/practice/434414efe5ea48e5b06ebf2b35434a9c

法一 用isupper()函数

while True:
try:
s=input()
res=0
for i in s:
if i.isupper():
res+=1
print(res)
except:
break
'''
#法二 用字符串的比大小!>='A' <='Z'
while True:
try:
n = input()
result = 0
for i in n:
if i >= 'A' and i <= 'Z':
result += 1
print(result)
except:
break

法三:用ord() ASCll表 <91 and ord(i)>64

while True:
try:
s = input()
n=0
for i in s:
if ord(i)<91 and ord(i)>64:
n=n+1
print(n)
except:
break
'''

全部评论
哥么🐂*呀!法四用正则表达式
点赞 回复 分享
发布于 2022-03-06 10:49

相关推荐

这是什么操作什么意思,这公司我服了...
斯派克spark:意思是有比你更便宜的牛马了
点赞 评论 收藏
分享
07-10 12:17
已编辑
商丘师范学院 Java
后来123321:别着急,我学院本大二,投了1100份,两个面试,其中一个还是我去线下招聘会投的简历,有时候这东西也得看运气
无实习如何秋招上岸
点赞 评论 收藏
分享
陈逸轩1205:才105 哥们在养生呢
点赞 评论 收藏
分享
评论
16
2
分享

创作者周榜

更多
牛客网
牛客网在线编程
牛客网题解
牛客企业服务