标签:tar query sdi mil pass 例题 错误 span pre
#数据怎么存 name_info = {"lisi":[‘123456‘,‘15512345678‘,5000.1]} #查询 def Query_yue(username): #取出登录用户的余额 print(f"{username}的账户余额为:{name_info[username][2]}") # 存款 def deposit(username): a = int(input("请输入存款金额:")) b = name_info[username][2] + "a" print(f"{username}的账户余额为:{b}") # 转账 def withdraw(username): x = input("请输入转账金额:") d = {name_info[username][2]} - {x} if d in name_info: print("转账成功,您的余额为:" "d") else: print("转账失败,请重新操作") print(f"{username}的账户余额为:{name_info[username][2]}") # 取款 def Transfer(username): a = input("请输入取款金额:") c = {name_info[username][2]} - {a} print(f"{username}的账户余额为:{c}") #登录后的界面函数 def login1(username): print(‘**********欢迎来到操作页面************‘) a = input("请输入操作值:1查询、2存款、3转账、4、取款、5、退出:") if a == ‘1‘: #查询 Query_yue(username) elif a == ‘2‘: #存款 deposit(username) elif a == ‘3‘: #转账 withdraw(username) elif a == ‘4‘: #取款 Transfer(username) elif a == ‘5‘: ATM() else: print("输入操作值有误,请重新输入") login1() #实现主页面 def login(): idx = 0 while idx < 3: print("**********欢迎来到登录页面************") username = input("请输入您的用户名:") password = input("请输入密码:") if username in name_info: #判断字典里面的用户密码和输入的密码是否一致 if name_info[username][0] == password: print("恭喜您登录成功,即将进入登录后页面") login1(username) else: print("用户名或者密码错误") print(f‘还剩:{2-idx}次机会‘) idx += 1 #如果输入错误进入主界面 ATM() def reg(): while True: print("**********欢迎来到注册页面************") username = input("请输入您的用户名:") #p判断用户名是否存在字典里,如果存在则让他重新输入,如果不存在判断用户名的合法性 if username in name_info: print("用户名存在,请重新输入") reg() else: if 6 <= len(username) <= 12 and username.isalnum(): password = input("请输入密码:") new_password = input("请输入确认密码") if 6 <= len(password) <= 16 and password.isalnum() and password==new_password: phone = input("请输入手机号码") if len(phone) == 11 and phone.isdigit() and phone.startswith(‘1‘): name_info[username] = [password,phone,5000] print("恭喜你,已经注册成功,请输入您的操作值:1代表登录、2代表注册、3代表退出:") ATM() else: print("密码输入有误,请重新输入") reg() else: print("用户名输入格式有误,请重新输入") reg() #主界面实现的思路:1代表登录、2代表注册、3代表退出,输入错误时需要重新返回到主页面 def ATM(): print("**********欢迎进入蜗牛ATM************") input_one = input("请输入您的操作值:1代表登录、2代表注册、3代表退出:") while True: if input_one == "1": login() elif input_one == "2": reg() elif input_one == "3": exit() else: print("输入有误,请重新输入操作值") ATM() ATM()
#数据怎么存
name_info = {"lisi":[‘123456‘,‘15512345678‘,5000.1]}
#查询
def Query_yue(username):
#取出登录用户的余额
print(f"{username}的账户余额为:{name_info[username][2]}")
# 存款
def deposit(username):
a = int(input("请输入存款金额:"))
b = name_info[username][2] + "a"
print(f"{username}的账户余额为:{b}")
# 转账
def withdraw(username):
x = input("请输入转账金额:")
d = {name_info[username][2]} - {x}
if d in name_info:
print("转账成功,您的余额为:" "d")
else:
print("转账失败,请重新操作")
print(f"{username}的账户余额为:{name_info[username][2]}")
# 取款
def Transfer(username):
a = input("请输入取款金额:")
c = {name_info[username][2]} - {a}
print(f"{username}的账户余额为:{c}")
#登录后的界面函数
def login1(username):
print(‘**********欢迎来到操作页面************‘)
a = input("请输入操作值:1查询、2存款、3转账、4、取款、5、退出:")
if a == ‘1‘:
#查询
Query_yue(username)
elif a == ‘2‘:
#存款
deposit(username)
elif a == ‘3‘:
#转账
withdraw(username)
elif a == ‘4‘:
#取款
Transfer(username)
elif a == ‘5‘:
ATM()
else:
print("输入操作值有误,请重新输入")
login1()
#实现主页面
def login():
idx = 0
while idx < 3:
print("**********欢迎来到登录页面************")
username = input("请输入您的用户名:")
password = input("请输入密码:")
if username in name_info:
#判断字典里面的用户密码和输入的密码是否一致
if name_info[username][0] == password:
print("恭喜您登录成功,即将进入登录后页面")
login1(username)
else:
print("用户名或者密码错误")
print(f‘还剩:{2-idx}次机会‘)
idx += 1
#如果输入错误进入主界面
ATM()
def reg():
while True:
print("**********欢迎来到注册页面************")
username = input("请输入您的用户名:")
#p判断用户名是否存在字典里,如果存在则让他重新输入,如果不存在判断用户名的合法性
if username in name_info:
print("用户名存在,请重新输入")
reg()
else:
if 6 <= len(username) <= 12 and username.isalnum():
password = input("请输入密码:")
new_password = input("请输入确认密码")
if 6 <= len(password) <= 16 and password.isalnum() and password==new_password:
phone = input("请输入手机号码")
if len(phone) == 11 and phone.isdigit() and phone.startswith(‘1‘):
name_info[username] = [password,phone,5000]
print("恭喜你,已经注册成功,请输入您的操作值:1代表登录、2代表注册、3代表退出:")
ATM()
else:
print("密码输入有误,请重新输入")
reg()
else:
print("用户名输入格式有误,请重新输入")
reg()
#主界面实现的思路:1代表登录、2代表注册、3代表退出,输入错误时需要重新返回到主页面
def ATM():
print("**********欢迎进入蜗牛ATM************")
input_one = input("请输入您的操作值:1代表登录、2代表注册、3代表退出:")
while True:
if input_one == "1":
login()
elif input_one == "2":
reg()
elif input_one == "3":
exit()
else:
print("输入有误,请重新输入操作值")
ATM()
ATM()
标签:tar query sdi mil pass 例题 错误 span pre
原文地址:https://www.cnblogs.com/blog-apply/p/13202259.html