该代码用于验证密码列表,但现在并不重要。我无法弄清楚为什么在循环时它不检查值2w3E*
。当我运行它时,它只需要-列表中的0、1和3值。当我打印以下任何条件的值时,它会打印所有值。我认为,即使在print
以下,也可以检查所有值。这是为什么?
pswds = 'ABd1234@1,a F1#,2w3E*,2We3345'
pswds = pswds.split(',')
for pswd in pswds:
print('PSWD', pswd)
confirmation = [0,0,0,0]
if 6 <= len(pswd) and len(pswd) <= 12:
for letter in pswd:
if letter.isalpha() and not letter.isupper():
confirmation[0] = 1
elif letter.isdigit():
confirmation[1] = 1
elif letter.isupper():
confirmation[2] = 1
elif letter in ['$','#','@']:
confirmation[3] = 1
if confirmation != [1, 1, 1, 1]:
pswds.remove(pswd)
else:
pswds.remove(pswd)
print('confirmed', pswds)
控制台输出
PSWD ABd1234@1
PSWD a F1#
PSWD 2We3345
confirmed ['ABd1234@1', '2w3E*']