|
发表于 2020-7-21 18:07:42
From FishC Mobile
|
显示全部楼层
|阅读模式
马上注册,结交更多好友,享用更多功能^_^
您需要 登录 才可以下载或查看,没有账号?立即注册
x
本帖最后由 Fish888 于 2020-7-21 19:30 编辑
- def vmm(st):
- da=0
- #左侧大写字母数量
- mima=''
- #最终密码字符串
- for i in range(0,len(st)-3):
- if st[i].isupper():
- da+=1
- #累计左侧大写字母数量
- else:
- if da==3 and st[i].islower() and st[i+1].isupper() and st[i+2].isupper() and st[i+3].isupper() and ((not st[i+4].isupper() )or i+4>len(st)):
- #如果左侧三个大写,当前位是小写,右侧三个是大写,右侧第四个不是大写或者超出字符长度
- mima+=st[i]
- da=0
- #只要不是大写就重置计数
- return mima
- print(vmm(''))
复制代码
ABSaDKSbRIHcRHGcdDIF找密码的结果是abc。
作业发布页面的string2文件找密码的结果是ilovefishc,
因为有空格,所以不能在if st[i].isupper():下面用else:来表示其他符合小写,
而必须用islower判断st/[i/]是小写 |
|