#Author:王帅帅的升级打怪之路
'''登陆界面可实现功能:
注册(可检测是否重名);
登陆(输错三次锁定);
注销账户(输错三次锁定)。
可实现注册后接着登陆或者注销账户。'''
#储存用户名和密码的列表。
usernameANDpassword_list = [["mac", "abc123"], ["apple", "6789bnm"], ["pencil", "123456"]]
UserChoice= input("Enter register, login or delete.")
Judgement=TruewhileJudgement:if UserChoice == "register":
flag1=Truewhileflag1:
username= input("Register:input a username.")
keyV= 0 #用于判断注册输入的用户名是否已存在。
for i inusernameANDpassword_list:if username ==i[0]:
keyV+= 1
else:
keyV+=0if keyV !=0:print("The name already exists, please try another one.")else:
password= input("Register:input your password.")
usernameANDpassword_list.append([username, password])print("you've already registered.")
flag1= False #注册成功之后跳出while循环
Continue = input("Please input N to exist or Y to continue other operations.")if Continue == "N":
Judgement=Falseelse:
UserChoice= input("Enter register, login or delete.")elif UserChoice == "login":
count=0
keyV=0while count < 3:
username= input("Login:input your username.")
password= input("Login:input your password.")for i inusernameANDpassword_list:if username == i[0] and password == i[1]:
keyV+= 1
else:
keyV+=0if keyV !=0:print("you've login!!!")
Continue= input("Please input N to exist or Y to continue login or delete.")if Continue == "N":
Judgement=Falseelse:
UserChoice= input("Enter register, login or delete.")break #退出while循环
else:print("your username or password is wrong.")
count+= 1
if count == 3:print("you've tried too many times.Your account has been locked.")
Judgement=Falseelif UserChoice == "delete":
count=0
keyV=0while count < 3:
username= input("Delete:input your username.")
password= input("Delete:input your password.")for i inusernameANDpassword_list:if username == i[0] and password == i[1]:
keyV+= 1
else:
keyV+=0if keyV !=0:
delete_confirm= input("Are you sure? \
Please input Y to delete or N to cancel.")if delete_confirm == "Y":
index=usernameANDpassword_list.index([username, password])delusernameANDpassword_list[index]print("your account has been deleted.")
Continue= input("Please input N to exist or Y to continue login or delete.")if Continue == "N":
Judgement=Falseelse:
UserChoice= input("Enter register, login or delete.")break
#usernameANDpassword_list.pop(index) 另一种删除方法。
else:print("you cancel this operation.")
Continue= input("Please input N to exist or Y to continue login or delete.")if Continue == "N":
Judgement=Falseelse:
UserChoice= input("Enter register, login or delete.")break
else:
count+= 1
if count == 3:print("you've tried too many times.")
Continue= input("Please input N to exist or Y to continue login or delete.")if Continue == "N":
Judgement=Falseelse:
UserChoice= input("Enter register, login or delete.")else:print("the username or password is wrong or unavailable.")else:print("you didn't correctly choose a function.")
Judgement= False