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