python习题:登录注册小程序

登录注册程序:

#1、账号/密码/密码确认
#2、非空
#3、已经存在的不能注册
all_user = {'niuhanyang':'123456','tlx':'123456'}
while True:
username = input('username:').strip()
pwd = input('pwd:').strip()
cpwd = input('cpwd:').strip()
if username and pwd and cpwd:
if username in all_user:
print('用户名已经存在,请重新输入')
else:
if pwd==cpwd:
all_user[username]=pwd
print('注册成功!')
break
else:
print('两次输入的密码不一致')
else:
print('账号/密码/确认密码不能为空')

#登录程序
# 1、非空
# 2、如果输入的用户名不存在,要提示
#3、输入账号密码
while True:
username = input('username:').strip()
pwd = input('pwd:').strip()
if username and pwd:
if username in all_user:
src_pwd = all_user[username]
if src_pwd == pwd:
print('欢迎登录')
break
else:
print('密码输入错误!')
else:
print('输入的用户不存在')
else:
print('账号/密码不能为空')

转载于:https://www.cnblogs.com/blackbird0423/p/8203451.html

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值