|
发表于 2019-7-26 18:04:15
|
显示全部楼层
本楼为最佳答案
本帖最后由 jermey1994 于 2019-7-26 23:06 编辑
- """
- a) 每位密码为单个小写字母
- b) 每位密码的左右两边均有且只有三个大写字母
- """
- str1 = '''ABSaDKSbRIHcRHGcdDIF'''
- key = str()
- lr_dict = dict()
- upper = False
- index = 0
- for s in str1 : # 遍历str1每个字符
- if s.islower() : #判断这个字符是否为字母的小写,是就往下对比
- lr_dict[str1[index-3:index]] = str1[index+1:index+4]
- for l,r in lr_dict.items() :
- if l.isupper() and r.isupper() :
- upper = True
- else :
- upper = False
- if upper :
- key += s
- lr_dict.clear()
- index += 1
- print('key : %s' % key)
- -->> key : abc
复制代码 |
|