Try语句运行不正确?

2024-09-21 01:16:49 发布

您现在位置:Python中文网/ 问答频道 /正文

我在做一个简单的程序,在循环中检查密码是否正确。我注意到我的try语句不起作用。这是我的密码:

listfile = open("list.txt","r")
def trial():
    for code in listfile:
        try:
            google.login(victim,"none")
            print("test")
            print("[!]Trial and error complete. Password is: %s"%code)
            break
        except smtplib.SMTPAuthenticationError:
            print("test")
            print("Incorrect password:%s"%code)
trial()

我知道try的说法是有效的。我通过添加行print("Test")来测试它,但是当我运行它时它没有出现。你知道吗

编辑:

try语句现在正在运行,但它总是引发错误。我知道它这样做是因为它正在运行第10行和第11行,通过打印“不正确的密码:”。我看到它打印了“Inncorrect password:”即使输入的密码是正确的。你知道吗


Tags: test程序txt密码fordefcodepassword
1条回答
网友
1楼 · 发布于 2024-09-21 01:16:49

您的登录信息不正确。你知道吗

try块中,有print("[!]Trial and error complete. Password is: %s" % code)

但是当您登录时,您的密码是“none”:google.login(victim,"none")

把那行改成google.login(victim, code)

相关问题 更多 >

    热门问题