一、系统说明
请你编写一个银行取款系统程序,要求具备以下几点功能。
1.开户业务
一个证件号码只可以绑定一个账号,系统首先验证用户证件号码,
如证件已在系统存在则不提供开户业务。
2.登陆系统
用户通过账号和密码登录系统,验证通过进入系统进行操作。
3.存款业务
用户登陆系统后,选择存款业务,即可以将输入的存款金额存入相应的账户。
4.取款业务
用户登陆系统后,选择取款业务,即可以将输入的取款金额从相应的账户取出,
如取款金额大于当前存款金额提示账户余额不足。
5.查询业务
用户登陆系统后,可以选择查询业务,查询账户余额。
6.转账业务
用户登陆系统后,可以选择转账业务,进行转账。收款账号必须是系统已经存在的账户。
7.修改密码
用户登陆系统后,可以选择修改密码业务,进行密码修改。
8.注销业务
用户登陆系统后,可以选注销业务,注销完成自动退出操作。
9.退出系统
如用户各类业务办理完成或无业务需求,可选择退出系统操作。
二、用户信息
{ "123001": [ "111111", "小新", "12130001", 13000 ], "123002": [ "222222", "风间", "12130002", 21000 ], "123006": [ "666666", "雯雯", "123006", 12000 ], "123008": [ "888888", "闻闻", "12130008", 12000 ], "123003": [ "333333", "妮妮", "12130003", 12000 ] }
三、取款系统
import json import time obtain = open('bank_customers.json', 'r', encoding='utf-8') data = json.loads(obtain.read()) Business_types = '''************************************ 1.存款业务 2.取款业务 3.查询业务 4.修改密码 5.转账业务 6.注销业务 7.退出系统 ************************************''' while True: operation = input('请您选择操作选项(1.登录系统 2.开通账户 3.退出系统):') if operation == '1': account = input('请您输入银行账号:') password = input('请您输入银行密码:') if account in data and password == data[account][0]: print('密码正确,登录成功') while True: times = time.strftime("%Y年%m月%d日 %H:%M:%S", time.localtime()) print('*' * 36) print(' ' * 10 + '欢迎使用漫漫取款系统') print('*' * 36) time.sleep(0.5) print('当前时间:{}'.format(times)) time.sleep(0.5) print(Business_types) business = input('请您选择需要办理业务:') if business == '1': print('您的存款余额是:{}'.format(data[account][3])) deposit = int(input('请您输入存款金额:')) data[account][3] = data[account][3] + deposit time.sleep(0.5) print('存款成功,您的余额是:{}'.format(data[account][3])) time.sleep(0.5) continues = input('是否需要继续办理业务(1.继续 2.退出):') if continues == '2': print('欢迎下次使用') break elif business == '2': print('您的存款余额是:{}'.format(data[account][3])) withdrawals = int(input('请您输入取款金额:')) if withdrawals <= data[account][3]: data[account][3] = data[account][3] - withdrawals time.sleep(0.5) print('取款成功,您的余额是:{}'.format(data[account][3])) else: print('取款失败,余额不足') time.sleep(0.5) continues = input('是否需要继续办理业务(1.继续 2.退出):') if continues == '2': print('欢迎下次使用') break elif business == '3': print('您的个人信息是:') print('用户姓名:{}'.format(data[account][1])) print('证件号码:{}'.format(data[account][2])) print('存款余额:{}'.format(data[account][3])) time.sleep(0.5) continues = input('是否需要继续办理业务(1.继续 2.退出):') if continues == '2': print('欢迎下次使用') break elif business == '4': while True: continues = input('是否需要继续办理业务(1.继续 2.退出):') if continues == '1': pass_input = input('请您输入原密码:') if pass_input == password: new_password = input('请您输入新的密码:') data[account][0] = new_password time.sleep(0.5) print('修改成功,新密码为:{}'.format(data[account][0])) time.sleep(0.5) break else: print('密码错误,请您核实!') elif continues == '2': break elif business == '5': print('您的账户余额是:{}'.format(data[account][3])) transfer = input('请您输入转账账号:') if transfer == account: print('对不起,自己不能给自己转账') time.sleep(0.5) continues = input('是否需要继续办理业务(1.继续 2.退出):') if continues == '2': print('欢迎下次使用') break else: if transfer in data: withdrawals = int(input('请您输入转账金额:')) if withdrawals <= data[account][3]: data[transfer][3] = data[transfer][3] + withdrawals data[account][3] = data[account][3] - withdrawals time.sleep(0.5) print('转账成功,您的余额是:{}'.format(data[account][3])) else: print('转账失败,余额不足') else: print('您输入的账号不存在') time.sleep(0.5) continues = input('是否需要继续办理业务(1.继续 2.退出):') if continues == '2': print('欢迎下次使用') break elif business == '6': cancellation = input('是否需要注销账号(1.注销 2.取消):') if cancellation == '1': del data[account] time.sleep(0.5) print('账号注销成功') break else: continues = input('是否需要继续办理业务(1.继续 2.退出):') if continues == '2': print('欢迎下次使用') break elif business == '7': print('欢迎下次使用') break else: if account not in data: print('账号错误,登录失败') else: print('密码错误,登录失败') back = input('是否需要找回密码(1.需要 2.退出):') if back == '1': name = input('请您输入用户姓名:') identity = input('请您输入证件号码:') if data[account][1] == name and data[account][2] == identity: new_password = input('请您输入新的密码:') data[account][0] = new_password time.sleep(0.5) print('重置密码成功') elif data[account][1] != name and data[account][2] == identity: print('输入姓名有误') elif data[account][1] == name and data[account][2] != identity: print('输入姓名有误') else: print('姓名和证件号码有误') elif back == '2': print('欢迎下次使用') elif operation == '2': while True: choose = input('是否继续操作(1.继续 2.退出):') if choose == '1': certificate = [] for i in data: certificate.append(data[i][2]) account = input('请您输入证件号码:') if account not in certificate: card = input('请您输入用户卡号:') password = input('请您输入用户密码:') name = input('请您输入用户姓名:') money = input('是否需要存款(1.需要 2.不存)') if money == '1': deposit = int(input('请您输入存入金额:')) data[card] = [password, name, account, deposit] else: data[card] = [password, name, account, 0] time.sleep(0.5) print('您的账户信息是账号:{}、密码:{}、姓名:{}、证件号码:{}、存款:{}' .format(card, data[card][0], data[card][1], data[card][2], data[card][3])) time.sleep(3) else: for i in data: if data[i][2] == account: print('不好意思您输入的证件号码已经绑定银行账号:{}。'.format(i)) elif choose == '2': break elif operation == '3': break print('欢迎您下次继续使用漫漫取款系统') data = dict(sorted(data.items(), key=lambda x: x[0])) save = open('bank_customers.json', 'w', encoding='utf-8') json.dump(data, save, ensure_ascii=False, indent=4)