0
    except Exception as e:
    ^
SyntaxError: invalid syntax

这是我的错误......我尝试了一切并广泛搜索了这个问题,但没有机会得到答案:(这是产生问题的代码:

except Exception as e:
print(e)
if e is "535, b'5.7.8 Username and Password not accepted. Learn more at\n5.7.8  https://support.google.com/mail/?p=BadCredentials w131sm7041527pfd.14 - gsmtp":
    print("Maybe, you should allow less secure apps on your google accounts settings... Or, check your 
    creditials")
    speak("Maybe, you should allow less secure apps on your google accounts settings, or 
    check your creditials")
    input("Would you like me to direct you to that page? [Y/N]")
    if "Y" or "y" in query:
    webbrowser.open("https://myaccount.google.com/lesssecureapps? 
    pli=1&rapt=AEjHL4P9nsZMthP9QP5I3QtZ4q_U0xn6Gaa2yJ4EMJpWk8Xdzuy06LknCJr6QJHe1EMfBjZ- 
    ODRg6V0Tn1X5nGUrzRvs3L-IjA")

     elif "N" or "n" in query:
     print("OK...")
     speak("OK!")

我不知道如何解决它,有人帮助我......

4

1 回答 1

0

请试试这个:

except Exception as e:
    print(e)
    if e is "535, b'5.7.8 Username and Password not accepted. Learn more at\n5.7.8  https://support.google.com/mail/?p=BadCredentials w131sm7041527pfd.14 - gsmtp":
        print("Maybe, you should allow less secure apps on your google accounts settings... Or, check your creditials")
        speak("Maybe, you should allow less secure apps on your google accounts settings, or check your creditials")
        input("Would you like me to direct you to that page? [Y/N]")
        if "Y" or "y" in query:
            webbrowser.open("https://myaccount.google.com/lesssecureapps?pli=1&rapt=AEjHL4P9nsZMthP9QP5I3QtZ4q_U0xn6Gaa2yJ4EMJpWk8Xdzuy06LknCJr6QJHe1EMfBjZ-ODRg6V0Tn1X5nGUrzRvs3L-IjA")
            elif "N" or "n" in query:
                print("OK...")
                speak("OK!")

它应该对你有用,就像现在有适当的缩进一样。

于 2020-12-01T13:38:49.467 回答