基本上,我是为了好玩而创建一个密码生成器,我使用一个记分系统来估计密码的强度。如果密码包含基于英国QWERTY键盘布局的连续三个字母,则从分数中减去5分,每组3.。
目前我有这个,但不起作用:
if password.isdigit():
points = points - 5
if password.islower():
points = points - 5
if password.isupper():
points = points - 5
from string import ascii_lowercase
if password.lower() in ascii_lowercase == True:
points = points - 5谢谢你的帮助!
发布于 2017-09-22 21:34:14
你随机地把两个不同的程序拼接在一起,很惊讶它不起作用。这会造成一些不一致的情况,比如降低输入,但随后进行测试,以确保它不是全部小写;计算负points,而是一个正的score;等等。让我们重新排序这些步骤,并使点分配一致:
LINES = ["qwertyuiop", "asdfghjkl", "zxcvbnm"]
triples = []
for line in LINES:
triples.extend(line[i:i + 3] for i in range(len(line) - 2))
password = input().strip()
points = 0
if password.isdigit() or password.islower() or password.isupper():
points -= 5
for triple in triples:
occurrences = password.count(triple)
points -= 5 * occurrences
print("Your password earned {} points".format(points))https://stackoverflow.com/questions/46372361
复制相似问题