python123登录注册_【python入门】简单实现注册、登陆、删除账户

#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

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值