|
发表于 2019-6-16 00:11:38
|
显示全部楼层
def count(str1):
c1,c2,c3,c4,c5,c6,c7,c8,c9,c0,c11,c12,c13,c14,c15,c16 = 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
for i in range(len(str1)):
if str1[i] == '!':
c1 +=1
if str1[i] == '@':
c2 +=1
if str1[i] == '#':
c3 +=1
if str1[i] == '$':
c4 +=1
if str1[i] == '%':
c5 +=1
if str1[i] == '^':
c6 +=1
if str1[i] == '&':
c7 +=1
if str1[i] == '*':
c8 +=1
if str1[i] == '(':
c9 +=1
if str1[i] == ')':
c0 +=1
if str1[i] == '_':
c11 +=1
if str1[i] == '+':
c12 +=1
if str1[i] == '{':
c13 +=1
if str1[i] == '}':
c14 +=1
if str1[i] == '[':
c15 +=1
if str1[i] == ']':
c16 +=1
return list([c1,c2,c3,c4,c5,c6,c7,c8,c9,c0,c11,c12,c13,c14,c15,c16])
print(count(str1))
#1.
def findpassword(str2):
substr = ""
index = 3
while index<len(str2)-3:
count = 0
if not str2[index].isupper():
for i in range(3):
if str2[index-(i+1)].isupper() and str2[index+(i+1)].isupper():
count+=1
if count==3:
substr+=str2[index]
index += 1
return substr
print(findpassword(str2)) |
|