我正在创建一个简单的蛮力脚本,但我似乎无法弄清楚。我正在使用从this question接受的答案,但我无法'尝试'等于用户密码。下面是我使用的代码(来自链接的问题),并稍加改动。蛮力脚本
from string import printable
from itertools import product
user_password = 'hi' # just a test password
for length in range(1, 10): # it isn't reasonable to try a password more than this length
password_to_attempt = product(printable, repeat=length)
for attempt in password_to_attempt:
if attempt == user_password:
print("Your password is: " + attempt)
我的代码只是运行,直到它到达笛卡尔的末尾,并且从不打印最终答案。不知道发生了什么事。
任何帮助,将不胜感激!
提示:什么是'attempt'的类型? – Kevin