题目

python  阶段案例-银行管理系统 P118


分析部分


代码部分

import randomclass bankUser:# 卡号,用户姓名,身份证号,手机,预存,密码Count_id = ""Count_Name = ""Count_IDCard = ""Count_phone = ""Count_Money = 0.00Count_password = ""Count_Root = Truedef __init__(self, Count_id, Count_IDCard, Count_Name, Count_phone, Count_Money, Count_password, Count_Root):self.Count_id = Count_idself.Count_IDCard = Count_IDCardself.Count_phone = Count_phoneself.Count_Money = Count_Moneyself.Count_password = Count_passwordself.Count_Root = Count_Rootself.Count_Name = Count_Nameclass DaoServer:# 检测账号是否已经被锁def isLock(self, i_id):with open("F:\\userFile.txt", 'r') as seaFile:mes = seaFile.readlines()for index in mes:matchId = index.split("~")[0]if matchId == i_id and index.split("~")[6] is False:return Truepassreturn False# 作用1:开户匹配是否有同样的身份证注册这个账户,有就返回假,没有返回真。传的参数是身份证号# 作用2:在查询时看看是否存在这个账号def searchBlock(self, IdCard):with open("F:\\userFile.txt", 'r') as seaFile:mes = seaFile.readlines()# id~pass~idcard~name~phone~moneyfor index in mes:matchIdcard = index.split("~")[1]matchId = index.split("~")[0]if matchIdcard == IdCard or matchId == IdCard:return Falsepassreturn True# 注册账户def register(self, user):if self.searchBlock(user.Count_IDCard):# 开始开户a = [1, 2, 3, 4, 5, 6, 7, 8, 9, 0]# 产生的一个账号numArray = random.sample(a, 6)# id~pass~idcard~name~phone~money# Count_id, Count_IDCard, Count_phone, Count_Money, Count_password, Count_Root# user.Count_id = ''.join(str(k) for k in numArray)# 用于生成的账户是否已经存在,如果存在就重新生成while not self.searchBlock(user.Count_id):numArray = random.sample(a, 6)# Count_id, Count_IDCard, Count_phone, Count_Money, Count_password, Count_Rootuser.Count_id = ''.join(str(k) for k in numArray)line = user.Count_id + "~" + user.Count_IDCard + "~" + user.Count_Name + "~" + user.Count_phone + "~" + str(user.Count_Money) + "~" + user.Count_password + "~" + str(user.Count_Root) + "\n"with open("F:\\userFile.txt", 'a+') as writeFile:writeFile.writelines(line)passreturn Trueelse:return False# 验证密码和账号是否一致# 正确返回user对象,否则返回Nulldef proof(self, pId, pPassword):with open("F:\\userFile.txt", 'r') as proofFile:proofMes = proofFile.readlines()for pIndex in proofMes:fId = pIndex.split("~")[0]fPassword = pIndex.split("~")[5]if fId == pId and fPassword == pPassword:f = bankUser(pIndex.split("~")[0], pIndex.split("~")[1], pIndex.split("~")[2], pIndex.split("~")[3],pIndex.split("~")[4], pIndex.split("~")[5], pIndex.split("~")[6])return freturn None# 锁控制函数 + 还可以进行重新数据更新后重新写入数据# 数据更新函数def Lock(self, lockU, res):lId = lockU.Count_idr_mes = []with open('F:\\userFile.txt', 'r') as rFile:r_mes = rFile.readlines()for r_index in r_mes:if r_index.split("~")[0] == lId:line = lId + "~" + r_index.split("~")[1] + "~" + r_index.split("~")[2] + "~" + r_index.split("~")[3] + "~" + str(lockU.Count_Money) + "~" + r_index.split("~")[5] + "~" + str(res) + "\n"r_mes.remove(r_index)r_mes.append(line)breakpasswith open('F:\\userFile.txt', 'w') as file:passwith open('F:\\userFile.txt', 'w') as file:for i in r_mes:file.writelines(i)pass# 查询账户def search(self, sId, sPassword):# 看看有没有这个账户# 参数:账户if not self.searchBlock(sId):# 存在这个账户,然后进行账户密码验证# 查看是否被锁定if self.isLock(sId):print("账号有危险,程序自动退出!")exit(0)res = self.proof(sId, sPassword)n = 1while res is None and n <= 3:sPassword = input("密码有误,请重新输入:")n = n + 1res = self.proof(sId, sPassword)if res is None:# 锁住,返回self.Lock(sId, False)print("有危险,账号已经锁住!")return Noneelse:# 打印信息print("=" * 50)print("||", " " * 13, res.Count_Name, " 先生(女士)", " " * 13, "||")print("||\t账户:", res.Count_id, " " * 6, "金额:", res.Count_Money, " " * 13, "||")print("=" * 50)return reselse:print("本行没有这个账户!")return Nonepass# 取款 | 存款#   1     2def getOrSaveMoney(self, flag, gId, gPassword):getRes = self.search(gId, gPassword)if getRes is None:return Noneelse:if flag is 1:money = int(input("请输入你要取的金额:"))getRes.Count_Money = int(getRes.Count_Money) - moneyif money <= 0 or money > int(getRes.Count_Money):print("输入有误")return getReselse:money = int(input("请输入你要存的金额:"))getRes.Count_Money = int(getRes.Count_Money) + moneyself.Lock(getRes, True)print(getRes.Count_Money)return getRes# 获取转向那个人的目标钱数def getGoalMoey(self, goalId):with open("F:\\userFile.txt", 'r') as seaFile:mes = seaFile.readlines()for index in mes:if index.split("~")[0] == goalId:return int(index.split("~")[4])pass# 转账def Transfer(self, tId, tPa):rRes = self.search(tId, tPa)if rRes is not None:if self.isLock(tId):print("此账号有危险,程序自动退出!")exit(0)# 转向账号goalId = input("请输入你要转向的那个人的账号:")if self.searchBlock(goalId):print("本行没有 ", goalId, " 这个账户")else:much = int(input("请输入你要转的金额:"))if much < 0 or much > int(rRes.Count_Money):print("输入有误,即将退出...")return Noneelse:u = bankUser(goalId, "", "", "", str(self.getGoalMoey(goalId) + much), "", True)# def Lock(self, lockU, res):self.Lock(u, True)rRes.Count_Money = int(rRes.Count_Money) - muchself.Lock(rRes, True)print("已经完成转账!")else:print("本行没有 ", tId, " 这个账户")def welcomeView():print("*" * 40)print("***", " " * 32, "***")print("***", " " * 32, "***")print("***", " " * 7, "欢迎登录银行管理系统", " " * 7, "***")print("***", " " * 32, "***")print("***", " " * 32, "***")print("*" * 40)def functionView():print("*" * 50)print("***", " " * 42, "***")print("***\t1.开户(1)", " " * 20, "2.查询(2)\t   ***")print("***\t3.取款(3)", " " * 20, "5.存款(4)\t   ***")print("***\t5.转账(5)", " " * 20, "6.锁定(6)\t   ***")print("***\t7.解锁(7)", " " * 32, "***")print("***", " " * 42, "***")print("***\t退出(Q)", " " * 35, "***")print("***", " " * 42, "***")print("*" * 50)welcomeView()
print("欢迎管理员前来工作:")
b = True
m_id = input("请输入管理员账号:")
while b:if m_id == "admine":breakelse:m_id = input("请重新输入管理员账号:")
pas = input("请输入管理员密码:")
a = True
m_pas = input("请输入管理员密码:")
while a:if m_pas == "123":breakelse:m_pas = input("请重新输入管理员密码:")functionView()
type = input("请输入你的操作:")
while type is not 'Q':if type == "1":u_name = input("请输入你的姓名:")u_phone = input("请输入你的电话:")u_idCard = input("请输入你的身份证号:")u_money = input("请输入你的预存金额:")u_pass = input("请输入你的密码:")u_user = bankUser("", u_idCard, u_name, u_phone, int(u_money), u_pass, True)d1 = DaoServer()boo = d1.register(u_user)if boo:print("注册成功!")else:print("注册失败!")elif type == "2":s_id = input("请输入你的账户:")s_pass = input("请输入你的密码:")d2 = DaoServer()d2.search(s_id, s_pass)elif type == "3":d3 = DaoServer()g_id = input("请输入你的账户:")g_pass = input("请输入你的密码:")d3.getOrSaveMoney(1, g_id, g_pass)elif type == "4":d4 = DaoServer()s_id = input("请输入你的账户:")s_pass = input("请输入你的密码:")d4.getOrSaveMoney(2, s_id, s_pass)elif type == "5":t_id = input("请输入你的账户:")t_pass = input("请输入你的密码:")d5 = DaoServer()d5.Transfer(t_id, t_pass)elif type == "6":d5 = DaoServer()p_id = input("请输入你的账户:")p_pass = input("请输入你的密码:")flag = d5.proof(p_id, p_pass)if flag is not None:d5.Lock(flag, False)print("锁定成功!")else:print("锁定失败")elif type == "7":d6 = DaoServer()ul_id = input("请输入你的账户:")ul_pass = input("请输入你的密码:")flag = d6.proof(ul_id, ul_pass)if flag is not None:d5.Lock(flag, True)print("解锁成功")else:print("解锁失败")elif type =="Q" or type == "q":exit(0)else:print("输入有误请重新输入:")type = input("请输入你的操作:")functionView()

python银行管理系统相关推荐

  1. python银行管理系统源码_javaweb银行大厅自助信息管理系统,源码行行注释,免费分享...

    全微毕设擅长JAVA(SSM,SSH,SPRINGBOOT).PYTHON(DJANGO/FLASK).THINKPHP.C#.安卓.微信小程序.MYSQL.SQLSERVER等,欢迎咨询 今天记录的 ...

  2. Python基础项目实践之:面向对象方法实现模拟银行管理系统

    Python课堂基础实践系列: Python基础项目实践之:学生信息管理系统 python基础项目实践之: 学生通讯录管理系统 Python基础项目实践之:面向对象方法模拟简单计算器 Python基础 ...

  3. python实例-银行管理系统(特简单的那种)

    python实例学习--银行管理系统 任务分析 管理员类 ATM类 主函数 注意 任务分析 这个实例要求实现一个银行管理系统,系统开始运行时,进入欢迎界面,工作人员输入管理员账户和密码,输入失败直接退 ...

  4. Python版简易银行管理系统源代码,银行管理系统python代码、银行自助提款系统

    Python版简易银行管理系统源代码,银行管理系统python代码,实现开户.账户查询.存取款.转账.改密.锁定.解锁.补卡.销户等银行管理操作.账户信息存在allusers.txt中,通过该文件的读 ...

  5. [附源码]Python计算机毕业设计Django小型银行管理系统

    项目运行 环境配置: Pychram社区版+ python3.7.7 + Mysql5.7 + HBuilderX+list pip+Navicat11+Django+nodejs. 项目技术: dj ...

  6. [附源码]计算机毕业设计Python小型银行管理系统(程序+源码+LW文档)

    该项目含有源码.文档.程序.数据库.配套开发软件.软件安装教程 项目运行 环境配置: Pychram社区版+ python3.7.7 + Mysql5.7 + HBuilderX+list pip+N ...

  7. 银行管理系统(使用SQL Server)-Python快速编程入门(第2版)-人民邮电出版社-阶段案例

    阶段案例-银行管理系统 题目描述 银行管理系统是一个集开户.查询.取款.存款.转账.锁定.解锁.退出等一系列业务于一体的管理系统,随着计算机技术在金融行业的广泛应用,银行企业采用管理系统替代了传统手工 ...

  8. python银行自动取款机系统详写

    1.确定对象与方法 人 类名: Person 属性: 姓名 身份证号 电话号 卡 行为: 卡 类名: Card 属性: 卡号 密码 余额 行为: 银行 主程序 类名: Bank 属性: 行为: 用户列 ...

  9. 使用类的银行管理系统的C ++程序

    In this program, we are using the concept of C++ class and object, following basic operations are be ...

最新文章

  1. linux avahi-daemon进程 网络服务 简介
  2. SQL Union 和 Union All 的区别以及二者的性能问题 - 使用Sqlite演示
  3. 未来数据中心运营将靠人工智能和机器学习
  4. C#Winform调用wsdl接口webservice#http
  5. 为什么要学习汇编语言?如何正确学习汇编语言?
  6. Spring Boot + Jersey发生FileNotFoundException (No such file or directory)
  7. SQL server 列值转列行
  8. 宜普电源转换公司(EPC)于2018年WiPDA宽能隙功率器件及应用论坛与工程师作技术交流
  9. 格雷码与二进制的转换 verilog实现加仿真
  10. dw怎么做html鼠标变化,dw鼠标经过单元格变色 DW 鼠标经过表格 背景变色
  11. 超级干货:手把手教你如何实现数据可视化
  12. linux下img文件 windows查看器,Windows server 2016 设置使用照片查看器查看图片
  13. 关于maven同名jar包不同版本号的冲突问题
  14. 【2022研电赛】安谋科技企业命题一等奖:基于EAIDK-610的中国象棋机器人对弈系统
  15. week11作业——C - 必做题11-3
  16. 关于内存、外存、磁盘、硬盘、软盘、光盘的区别
  17. 第四章 Pandas统计分析基础
  18. 用ps制作动态的地球旋转图片
  19. 电脑怎么了--电脑通电电源风扇不转动
  20. Wormhole大数据流式处理平台五大功能

热门文章

  1. 一个很不错的jsoneditor组件
  2. NRF24L01 大数据分包组包传输
  3. Gophish:开源网络钓鱼工具包
  4. Linux服务器编程--升序链表定时器和时间轮定时器的比较
  5. BurpSuit暴力破解密码
  6. 论文研读-多因子进化算法中的自适应知识迁移MFEA-AKT
  7. 团队程序设计天梯赛考点内容总结(15分以上题)
  8. mysql连接数据库的三种方法(连接池,jdbc,Hibernate)
  9. 《Linux系统调用:opendir,readdir,closedir,rewinddir》
  10. 【总结】56个JavaScript 实用工具函数助你提升开发效率!