【发布时间】:2017-03-09 20:41:51
【问题描述】:
我正在创建一个简单的蛮力脚本,但我似乎不太明白。我正在使用来自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的类型是什么?