You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

25 lines
575 B

# 假设的用户数据
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()