代码如下:
vip = 5
count = 3
user_name = ["ahu"]
user_pwd = ["1234"]
flag = 0
while flag == 0:
member = input("登录请按【1】\n注册请按【2】\n")
# 登录
if member == "1":
print("-----------------用户登录界面--------------------")
user = input("请输入账号:")
count -= 1
if user in user_name:
pwd = input("请输入密码:")
if pwd in user_pwd:
print("登录成功,欢迎", user, "使用~")
# 当账号密码都对的情况下 break
vip = 5
print("你将有%s次机会查询课表哦~" % (vip))
flag = 1
else:
if count == 0:
print("你的账号被锁定了,请稍后再试")
break
else:
print("密码错误!!!,你还有%s次机会" % (count))
else:
if count == 0:
print("你的账号被锁定了,请稍后再试")
break
else:
print("账号错误!!!,你还有%s次机会" % (count))
# 注册
if member == "2":
print("-----------------用户注册界面--------------------")
user = input("注册一个用户名:")
pwd = input("输入你的密码:")
# 将新增的账号密码添加进列表
user_name.append(user)
user_pwd.append(pwd)
print(user_name, user_pwd)
# 返回到登录界面
flag = 0
while flag == 2:
print("-----------------查询课表界面--------------------")