From 4f2fcfd3b8f1fc85521ad0ff772537cfc71a11ff Mon Sep 17 00:00:00 2001 From: pv6fcawes <2641155863@qq.com> Date: Tue, 2 Jul 2024 20:35:53 +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