python登陆界面尝试
2021-06-07 21:05
标签:view 输入 sed tin none xiaoxiao %s *** img 示例1: 示例1改进: python登陆界面尝试 标签:view 输入 sed tin none xiaoxiao %s *** img 原文地址:https://www.cnblogs.com/zhangchengchao123/p/14546294.html"""
编写一个程序
用户可以输入用户名和密码
用户有三次机会
登录成功可以进行相应的操作
输入Q退出系统
"""
name_list = ["zhangdada","wangxiaoxiao","lizhongzhong"]
pwd_list = ["123","456","789"]
info = ["1:存款","2:取款","3:转账","4:查询"]
print("欢迎使用本系统,退出请输入Q")
tag =True
i = 0
while tag:
name = input("请输入你的用户名:")
pwd = input("请输入你的密码:")
if name == "Q" or pwd == "Q": # 退出条件
tag = False
break
if i >= 2: # 输入次数判断
print("您今日的次数已用完,账户锁定!")
break
if name not in name_list or pwd not in pwd_list: # 登录逻辑
i += 1
print("用户名或者密码错误!")
continue
else:
for i in info: # 业务逻辑展示
print("****%s*****" % i)
while tag: # 业务逻辑循环
yewu = input("请输入你要办理的业务对应数字:")
if yewu == "Q": # 退出条件
tag = False
break
if yewu == "2":
print("您已取款:1000元")
elif yewu == "1":
print("您已存款:1000元")
elif yewu == "3":
print("您已转账: 3000元")
elif yewu == "4":
print("您的账户余额为:38028元")
else:
print("输入错误,请从新输入")
"""
编写一个程序
用户可以输入用户名和密码
用户有三次机会
登录成功可以进行相应的操作
输入Q退出系统
加入新用户注册功能
"""
name_list = ["zhangdada","wangxiaoxiao","lizhongzhong"]
pwd_list = ["123","456","789"]
info = ["1:存款","2:取款","3:转账","4:查询"]
while True:
print("欢迎使用本系统,用户登陆请输入1,新用户注册请输入2,退出请输入Q")
choose = input("请选择类型:")
if choose == "Q": # 退出行
tag_1 = False
break
# 新用户注册
if choose == "2":
while True:
name_new = input("请创建用户名:")
if name_new in name_list:
print("用户名已存在请重新输入!")
else:
name_list.append(name_new)
pwd_new = input("请设置密码:")
if pwd_new in pwd_list:
print("密码重复,请重新来过!")
name_list.remove(name_new)
continue
else:
pwd_list.append(pwd_new)
break
elif choose == "1" :
break
else:
print("输入错误,请重新来过!")
# 登陆部分和业务处理
tag = True
i = 0
while tag and tag_1:
name = input("请输入你的用户名:")
pwd = input("请输入你的密码:")
if name == "Q" or pwd == "Q": # 退出条件
tag = False
break
if i >= 2: # 输入次数判断
print("您今日的次数已用完,账户锁定!")
break
if name not in name_list or pwd not in pwd_list: # 登录逻辑
i += 1
print("用户名或者密码错误!")
continue
else:
for i in info: # 业务逻辑展示
print("****%s*****" % i)
while tag: # 业务逻辑循环
yewu = input("请输入你要办理的业务对应数字:")
if yewu == "Q": # 退出条件
tag = False
break
if yewu == "2":
print("您已取款:1000元")
elif yewu == "1":
print("您已存款:1000元")
elif yewu == "3":
print("您已转账: 3000元")
elif yewu == "4":
print("您的账户余额为:38028元")
else:
print("输入错误,请从新输入")