Commit ab079ec2 by BellCodeEditor

save project

parent 9e5d4bbe
Showing with 58 additions and 6 deletions
username = "搜索" # 保存在服务器数据库中的用户账号(正确的账号) username = "搜索" # 保存在服务器数据库中的用户账号(正确的账号)
userpassword = "123456" # 保存在服务器数据库中的用户密码(正确的 userpassword = "123456"#保存在服务器数据库中的用户密码(正确的
while True: while True:
name=input("请输入账号:") name=input("请输入账号:")
password=input("请输入密码:") password=input("请输入密码:")
break #break
if username==name and userpassword == password: if username==name and userpassword == password:
print("登陆日本成功") print("登陆日本成功")
break
else: if userpassword!=password and username!=name:
input("错误") input("帐号和密码错误")
# 请用input()实现用户输入账号、密码的功能
\ No newline at end of file if username!=name:
input("帐号错误")
if userpassword!=password:
input("密码错误")
# 请用input()实现用户输入账号、密码的功能
#input输出参数内容 输入 返回值
#print 输出
users = {
"zhangsan": "001",
"lisi": "002",
"wangwu": "003"
}
# 登录尝试次数
attempt_limit = 3
# 当前登录尝试次数
current_attempts = 0
def login():
global current_attempts
while current_attempts < attempt_limit:
username = input("请输入用户名:")
password = input("请输入密码:")
# 检查用户名是否存在
if username not in users:
print("用户名不存在,请重新输入!")
current_attempts += 1
continue
# 检查密码是否正确
if users[username] != password:
print("密码错误,请重新输入!")
current_attempts += 1
continue
# 用户名和密码都正确
print(f"欢迎 {username} 登录!")
return
# 如果三次尝试机会都用完,则给出提示并结束程序
print("您已连续三次输入错误,程序将退出。")
# 运行登录函数
login()
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment