100字范文,内容丰富有趣,生活中的好帮手!
100字范文 > python基础之模拟ATM 注册 登录 查询余额 存款 取款 转账 退卡(原代码)

python基础之模拟ATM 注册 登录 查询余额 存款 取款 转账 退卡(原代码)

时间:2022-09-26 12:30:22

相关推荐

python基础之模拟ATM 注册  登录  查询余额  存款  取款  转账  退卡(原代码)

curruent_users = Noneusers = [{'username': 'lili', 'password': '123456', 'banlance': 30000},{'username': 'tt',' password': '123478', 'banlance': 23000}]def getmuen():muen='''****欢迎来到WonluiuATM***********操作菜单***********1、注册 2、登录 3、查询余额 4、存款 5、取款 6、转账 7、退卡**** '''while True:print(muen)opt = input('请输入你想要选择的菜单:')if opt == '1':reg()elif opt == '2':login()elif opt == '3':search()elif opt == '4':deposit()elif opt == '5':withdrawal()elif opt == '6':tansform()elif opt == '7':print('欢迎下次光临')breakelse:print('请输入正确的数字')def reg():while True:p = input('请输入用户名:')m = input("请输入密码:")for item in users:if p == item['username']:print('用户已存在!!')breakelse:if len(m) < 6:print('密码小于6位数')breakelse:users.append({'username': p, 'password': m, 'banlance': 3000})print('用户注册成功,请重新登录!!')return Truedef login():while True:h = input('请输入用户名:')m = input("请输入密码:")for it in users:if it['username'] == h and it['password'] == m:print('用户登录成功')global curruent_userscurruent_users = itreturnelse:print('用户名或者密码错误!')def search():if curruent_users: #代表登录成功了print('当前用户得余额为:', curruent_users['banlance'])else:print('请先登录在查询')def deposit():if curruent_users:h = int(input('请输入存入的数目:'))if h % 100 == 0:curruent_users['banlance'] += hprint("目前的金额为 ", curruent_users['banlance'])else:print('请正确的金额')else:print('请先登录在查询')def withdrawal():if curruent_users:h = int(input('请输入取的数目:'))if h[-2:] == '00' and len(h) > 2:if curruent_users['banlance'] >= h:curruent_users['banlance'] -= helse:print('余额不足')else:print('请存取100的整数')else:print('请先登录在查询')def tansform():if curruent_users:h = input('请输入转账的账户名称')if curruent_users['username'] == h:print("不能给自己转账")else:for item in users:if item['username'] == h:f = input("请输入转账的金额")if h[-2:] == '00' and len(h) > 2:if curruent_users['banlance'] >= int(h):curruent_users['banlance'] -= int(h)curruent_users['banlance'] -= int(f)item['banlance'] += int(f)else:print('余额不足')else:print('输入的金额有误')breakelse:print('请输入正确的账户')else:print('请先登录在查询')getmuen()

本内容不代表本网观点和政治立场,如有侵犯你的权益请联系我们处理。
网友评论
网友评论仅供其表达个人看法,并不表明网站立场。