From df5c32a12ed8fb618b6260c7aa99c8706c02f973 Mon Sep 17 00:00:00 2001 From: p83ftenfl Date: Wed, 3 Jul 2024 21:13:46 +0800 Subject: [PATCH] ADD file via upload --- Python.txt | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100644 Python.txt diff --git a/Python.txt b/Python.txt new file mode 100644 index 0000000..2e94174 --- /dev/null +++ b/Python.txt @@ -0,0 +1,25 @@ +# 假设的用户数据 +USER_DATA = { + 'username': 'admin', + 'password': '1234' +} +# 尝试次数限制 +MAX = 3 + +def login(): + a = 0 + while a < MAX: + n = input("请输入用户名:") + p = input("请输入密码:") + if USER_DATA['username'] == n and USER_DATA['password'] == p: + print("登录成功") + return True + else: + print("登录失败,用户名或密码错误") + a += 1 + print(f"您还有 {MAX-a} 次尝试机会。") + print("登录失败次数过多,账户被锁定。") + return False + +if __name__ == "__main__": + login() \ No newline at end of file