📌  相关文章
📜  用户名和密码登录功能 - Python 代码示例

📅  最后修改于: 2022-03-11 14:46:00.037000             🧑  作者: Mango

代码示例1
def login():
    attempt = 3
    username = input("Enter your username:\n> ")
    while True:
     if username in userNamePassword:
        password = input("Enter your password:\n> ")
        if userNamePassword[username] == password:
            print("Logged in")
            return True
        elif userNamePassword[username] != password:
            attempt -=1
            print("Sorry, the password is invalid. You have", attempt,"attempts remaining.")  
            login()
            if attempt == 0:
             print("Sorry, you have exhausted your password attempts. Please restart the process.")
             break