嘿,我目前正在制作一个小工具,只是为了好玩。它可以使用用户名和密码列表并打印出所有可能的组合。
Python 2.7
我的代码
while True:
cnt = 1
cntpw = 1
currentusernameopen = open((usernamelist), "r")
linesim = currentusernameopen.read().split("\n")
usernameused = (linesim[cnt])
while True:
try:
currentpassopen = open((passwordlist), "r")
linesimpw = currentpassopen.read().split("\n")
pwused = (linesimpw[cntpw])
print usernameused+":"+pwused
cntpw += 1
except:
cnt += 1
但是当它到达passowrds的末尾时,它只会打印: USER1:
答案 0 :(得分:1)
编辑:我提出这样的练习:
#!/usr/bin/env python3
users = open("users", "r")
passwords = open("passwords", "r")
for user in users:
for password in passwords:
print("%s: %s" % (user.strip(), password.strip()))
passwords.seek(0)
strip删除所有尾随空格,这里是最后一个" \ n"