函数01
00
找出作者藏在下边这个长字符串中的密码,密码的埋藏点符合以下规律:
a) 每位密码为单个小写字母
b) 每位密码的左右两边均有且只有三个大写字母
str1 = '''指定字符串 '''
countl = 0
countm = 0
countr = 0 #规定左中右字符出现的次数
length = len(str1)
for i in range(length): #对每个字符进行检测
if str1[i] == '\n':
continue #回车换行不影响密码生成
if str1[i].isupper(): #大写时
if countm == 1: #已存在小写字符,右+1,左归0
countr += 1
countl = 0
else: #不存在小写字符
countl += 1
continue
if str1[i].islower() and countl == 3: #小写并左边已存在3个大写字符
countm = 1 #小写字符记作1
countl = 0 #左边字符归0
target = i
continue
if str1[i].islower() and countr == 3: #检测是字符是否符合要求
print(str1[target], end='')
countl = 0
countm = 0
countr = 0
浙公网安备 33010602011771号