Python意外阻止错误

时间:2017-03-02 15:38:15

标签: python

对不起,我有一个我不明白的问题......

def login_screen():
    print(30 * "-")
    print("   LOGIN")
    print(30 * "-")
    username = print("Please enter your username: ")
    password = print("Please enter your password: ")
        with open('logins.txt', 'r') as csvfile:
            loginreader = csv.reader(csvfile, delimiter=',', quotechar= None)
            for codes in loginreader:
                if len(codes) == L_LEN:
                    if codes[L_USERNAME] == username and codes[L_PASSWORD] == password and codes[L_ADMIN] == "Yes":
                        admin_console()
                    elif username == row[L_USERNAME] and password == row[PASSWORD] and row[L_ADMIN] == "No":
                        #Temp normal console here
                    else:
                        clearscreen()
                        error_head()
                        print("Unknown account")
                        input("Press [ENTER] To continue...")
                        login_screen()
                elif len(codes) != M_LEN:
                    next(csvfile, None)

所以问题是它带有以下错误:

  File "G:\Python\DatabaseStandardRewrite\Login.py", line 49
else:
   ^

IndentationError:预期缩进块

但我不明白! (是的,所有其他事情都在文件的其余部分中定义了!

你们有没有人看到我的错误?

纳坦

1 个答案:

答案 0 :(得分:2)

Python不允许块为空;你需要至少一个陈述,评论不计算在内。因此,在elif之前的else区块中,您应该放置pass

            elif username == row[L_USERNAME] and password == row[PASSWORD] and row[L_ADMIN] == "No":
                #Temp normal console here
                pass
            else:
                clearscreen()