python-3.x 我在if语句的缩进方面遇到了问题[关闭]

xqk2d5yq  于 2023-05-30  发布在  Python
关注(0)|答案(1)|浏览(177)

**已关闭。**此问题为not reproducible or was caused by typos。目前不接受答复。

此问题是由打印错误或无法再重现的问题引起的。虽然类似的问题在这里可能是on-topic,但这个问题的解决方式不太可能帮助未来的读者。
5小时前关闭
Improve this question
第53行a.LogIn出现错误(错误:应为缩进块)。我做错了什么?

Usernames = ["Placeholder"]
Passwords = ["Placeholder"]
Emails = ["Placeholder"]
username = "ph"
email = "ph"
password = "ph"
ModeActive = True

class functions:
    def CreateAccount():
        while username not in Usernames and len(username) <= 20 and username != "new" and "placeholder" in username:
            username = input("What should your username be? ")
            if len(username) >= 20:
                print("Your username is too long, please make sure to choose a username, shorter than 20 characters")
            elif username in Usernames:
                print("This username is already taken, please enter a different username.")
        print("Your username has been set to: " + str(username))
        while "@" and ".com" not in email and email in Emails:
            email = input("What is your email address? ")
            if "@" and ".com" not in email:
                print("You have entered a wrong email address. Please correct it.")
            elif email in Emails:
                print("This email is already taken.")
        print("Your email address has been set to: " + str(email))
        while len(password) >= 8 and len(password) <= 16:
            password = input("What should your password be? ")
            if len(password) <= 7:
                print("Your password is too short, please make sure that your password contains at least 8 characters.")
            elif len(password) >= 17:
                print("Your password is too long, please make sure that your password only contains a maximum of 16 characters.")
        print("Your password has been set to: " + str(password))
        Usernames.append(username)
        Passwords.append(password)
        Emails.append(email)

    def LogIn():
        while username not in Usernames:
            username = input("Enter your username: ")
            if username not in Usernames:
                print("This username is not given. Write 'new' to create an account.")
                if input("Enter username or type 'new' to create an account: ") == "new":
                    a.CreateAccount()
                elif username in Usernames:
                    print("You are trying to log in as: " + str(username))
        loginId = Usernames.index(username)
        requiredPassword = Passwords[loginId]
        while password != requiredPassword:
            if input("Enter your password: ") != requiredPassword:
                print("You have entered a wrong password.")
            elif input("Enter your password: ") == requiredPassword:
                print("Login successfull!")
        print("You have logged in as: " + str(username))
a = functions()

while ModeActive == True:
    if "log" and "in" in input("What do you want to do? "):
    a.LogIn
ru9i0ody

ru9i0ody1#

错误在第57行:

while ModeActive == True:
    if "log" and "in" in input("What do you want to do? "):
    a.LogIn #<- source of error

如下所示:

while ModeActive == True:
    if "log" and "in" in input("What do you want to do? "):
        a.LogIn

相关问题