代码:

#创建用户账号管理库
Account = [{'Name':'Jack','Password':'123456','Balance':3000}]
#定义主界面函数
def home_page():print('欢迎使用银行ATM自助存取款系统')print('''1.登陆账号2.注册账号3.退出系统''')
#定义登录功能界面函数
def option_page():print('您好%s' % Account[i]['Name']+',欢迎使用银行ATM自助存取款系统')print('''1.查询余额     2.自助取款3.自助存款     4.修改密码5.回主菜单     6.退出系统''')
#定义主界面判断函数
def judge1():while 1:home_page()judge_1 = input('请选择您需要的服务:')if judge_1 == '1':user_login()     #执行用户的登陆elif judge_1 == '2':name()new_account()judge1()elif judge_1 == '3':print('感谢您的使用,欢迎再次光临!')input('>>按确定键退出服务<<')exit()else:print('请输入选项中的有效数字!')input('>>按确定键继续为您服务<<')#定义一个功能界面判断函数
def judge2():while 1:option_page()  # 进入功能界面judge_2 = input('请选择您需要的服务:')if judge_2 == '1':print('您的账号余额为:%0.2f' % Account[i]['Balance'])input('>>按确定键继续为您服务<<')elif judge_2 == '2':sum = int(input('请输入你的取款金额:'))if Account[i]['Balance']-sum >= 0:  #判断余额是否足够balance = Account[i]['Balance'] - sumdict1 = {'Balance':balance}Account[i].update(dict1)  #更新账户余额print('恭喜您取款成功,取款金额为:%d,账户余额为:%d' % (sum,balance))input('>>按确定键继续为您服务<<')else:print('您的账号余额不足!')input('>>按确定键继续为您服务<<')elif judge_2 == '3':sum = int(input('请输入你的存款金额:'))total = sum + Account[i]['Balance']dict2 = {'Balance':total}Account[i].update(dict2)  #更新存款金额print('恭喜您存款成功,您的存款金额为:%d,账户余额为:%d' % (sum,total))input('>>按确定键继续为您服务<<')elif judge_2 == '4':rep_password()#进入修改密码函数input('>>按确定键继续为您服务<<')elif judge_2 == '5':judge1()#进入主菜单判断函数elif judge_2 == '6':print('感谢您的使用,欢迎再次光临!')input('>>按确定键退出服务<<')exit()else:print('请输入选项中的有效数字!')input('>>按确定键继续为您服务<<')
#定义一个登陆用户名判断函数
def user_login():k = 3  #定义允许用户输入错误的次数的变量while k:global iname()  #首先遍历账户信息,然后生成列表用于后面判断username = input('请输入您的用户名:')password = input('请输入6位用户密码:')for i in range(len(Account)):if username in list1_username and password in list2_password:  #遍历出来的用户名和密码在列表中,执行if username == Account[i]['Name']:if password == Account[i]['Password']:  # 用户名和密码匹配一致,执行judge2()  #进入功能界面判断breakelse:  #用户名和密码不匹配,执行print('用户名和密码不匹配,请重新输入!')#breakelif username == '' and password == '':  # 密码和用户输入为空,执行print('用户名和密码不能为空,请重新输入!')breakelif username not in list1_username or password not in list2_password:  # 用户名或密码不在列表中,执行k -= 1if k == 1:print('用户名或密码输入错误已达2次,再次输入错误将返回主菜单!')breakelif k == 0:print('用户名或密码输入错误已达3次,系统自动返回主菜单!')input('>>按确定键返回主菜单<<')judge1()print('用户名或密码输入错误,请重新输入!')break
#定义一个修改密码函数
def rep_password():#while 1:password = input('请输入6位原密码:')#if len(password) == 6 and password.isdigit():#print("输入错误,请输入6位数字密码!")#rep_password()if password == Account[i]['Password']:   #密码与原密码一致,执行while 1:new_password1 = input('请输入6位新密码:')new_password2 = input('请再次输入6位新密码:')if new_password1 == '' and new_password2 == '':print('密码不能为空,请重新输入!')continue# 如果数字密码是6位一致的密码,执行elif new_password1 == new_password2 and (len(new_password2) ==6 and new_password2.isdigit()):dict2 ={'Password':new_password2}#Account[i]['password'] = new_password2Account[i].update(dict2)print('恭喜您,密码修改成功!')break# 如果数字密码不是6位一致的密码,执行elif new_password1 == new_password2 and (len(new_password2) !=6 or new_password2.isdigit()):print('密码长度输入错误,请输入6位有效数字密码!')continue# 如果不是数字密码,执行elif new_password1 == new_password2 and (len(new_password2) ==6 or new_password2.isdigit()):print('密码应为纯数字密码,请输入6位有效数字密码!')continue# 判断两次密码输入是否一致,不一致重新输入elif new_password1 != new_password2:print('两次输入的密码不一致,请重新输入!')continue# 输入密码与原密码不一致,执行elif password != Account[i]['Password']:print('原密码输入错误,请重新输入!')rep_password()    # 递归执行密码输入else:print('请输入有效数字,谢谢!')
#定义一个用户遍历函数
def name():global usernameglobal passwordglobal list1_usernameglobal list2_passwordlist1_username = []list2_password = []for j in range(len(Account)):all_username = Account[j]['Name']list1_username.append(all_username)    # 将遍历出来的用户存到列表all_password = Account[j]['Password']list2_password.append(all_password)   # 将遍历出来的密码存到列表
#定义一个实现用户注册的函数
def new_account():while 1:# 设置新用户名添加到用户库while 1:new_username = input('请输入您的用户名:')if new_username in list1_username:print('用户名已存在,请重新输入!')elif new_username == '':print('用户名不能为空,请重新输入!')else:new_user = {'Name': new_username}Account.append(new_user)break# 设置新用户名的登陆密码添加到用户库while 1:new1_password = input('请输入您的6位数字密码:')new2_password = input('请再次输入您的6位数字密码:')if new1_password == '' and new2_password == '':print('密码不能为空,请重新输入!')elif new1_password == new2_password:if len(new2_password) == 6 and new2_password.isdigit():new_user['Password'] = new2_passwordprint('***恭喜您,新账户注册成功!***')breakelif len(new2_password) != 6:print('密码长度不正确,请重新输入!')elif len(new2_password) == 6 or new2_password.isdigit():print('密码不是纯数字密码,请重新输入')elif new1_password != new2_password:print('两次输入密码不一致,请重新输入!')# 新用户预存金额select = input('是否需要预存金额,需要请输入“1”后按确认键:')if select == '1':new_balance = int(input('请输入您预存金额:'))new_user['Balance'] = new_balanceprint('预存款成功!存款金额为:%d' % new_balance)input('>>按确定键返回主菜单<<')breakelse:input('>>按确定键返回主菜单<<')break
#主运行函数
while 1:judge1()

运行结果:





Python函数实现银行自助存取款系统相关推荐

  1. C语言实现银行ATM存取款系统 | 附源码

    点击蓝字 关注我们 来源于网络,侵删 银行ATM存取款系统 银行ATM存取款系统业务描述如下: 银行ATM存取款系统能为用户提供存款.取款.查询.转账和修改密码的功能.为了模拟真实的ATM业务环境,本 ...

  2. 银行ATM存取款系统(C语言实现)

    这里使用的运行工具是DEV C++.老铁们一定要看仔细了.是DEV C++ 仅供借鉴:这个是大一时期写的.大四的时候整理了一下(本人C语言学的也不太好).肯定很多不足和存在漏洞的地方.仅供借鉴.仅供借 ...

  3. 模拟银行ATM自助存取款系统

    #include<stdio.h> #include<stdlib.h> #include<time.h> #include<string.h> int ...

  4. java银行atm存取款系统_各位大佬,如何用JAVA实现银行ATM机的用户登录以及存取款...

    该楼层疑似违规已被系统折叠 隐藏此楼查看此楼 package com.wooyoo.learning.bank; import java.util.Scanner; public class test ...

  5. 利用Java基础知识+简单封装写一个银行登录存取款系统

    文章目录

  6. 银行存取款系统(python)

    今天,我做了个简单的小程序,给大家分享一下. # 定义主界面函数 def home_page():print('=' * 20 + '欢迎使用棁银行ATM自助存取款系统' + '=' * 20)pri ...

  7. java写一个简单的银行存取款系统

    package com.coding.study09;import java.util.Scanner;public class Demo01 {public static void main(Str ...

  8. 用python开发一个银行存取款系统

    #用python开发一个银行存取款系统ka1='1001' #卡号 pa1='123456' #密码 ye1=1000 #余额 nb=0 #业务类型 qu=None #取款金额 cu=None #存款 ...

  9. 银行活期存取款业务处理系统的数据流图

    银行活期存取款业务处理系统的数据流图 (1)数据源(数据的源点)包括:__储户______: (2)加工包括:________: (3)数据存储包括:_账目文件.现金帐_______&#x

最新文章

  1. android 隐藏闹钟通知,redis环境搭建
  2. qt槽函数如何传递多个参数_Qt:在发出信号后尝试将多个引用传递给槽函数
  3. Maven-Dependency Mechanism
  4. 一级减速器装配图cad文件_减速器的基本结构,减速箱各组成零件的结构及功用,值得保存...
  5. 【java异常】No enum constant org.apache.ibatis.type.JdbcType.number
  6. python编程入门-python编程入门(第3版)
  7. Pyinstaller将外部数据文件打包到可执行文件中(onefolder or onefile)教程
  8. 中国首座!智慧机场建成投运,BIM技术打造数字底图
  9. Web基础知识与常用技术
  10. 安装虚拟机后无法获取 vmci 驱动程序版本句柄无效解决方法!
  11. 学术论文中常见的英文简写
  12. Linux三剑客学习笔记
  13. 什么是Web 3.0 ?
  14. echarts gl在地球上添加发光柱
  15. MySQL索引的前世今生
  16. 百度贴吧如何避免被删帖
  17. 《小额贷款操作系统》MVC文献
  18. hana-ui - 一个清新二次元风格的React-UIKit
  19. win10操作系统系统,小米路由器,小米3 的问题
  20. SolidWorks 2019 工作界面

热门文章

  1. 费翔林, 骆斌. 操作系统教程(第五版).Page118第19题笔记
  2. 利用java实现天气预报设计教程视频_java实现天气预报(解释+源代码)
  3. [深入理解SSD系列综述 1.5] SSD固态硬盘参数图文解析_选购固态硬盘就像买衣服?
  4. 变电站运维云平台系统在台商大厦的设计与应用
  5. 开发者说论文|人工智能为设备磨损“把脉”:依托飞桨开展的铁谱图像智能故障诊断研究...
  6. 07_《计算机安全原理与实践》数据安全随笔
  7. 一个赌单双游戏的预测和想法
  8. American ,they say....
  9. 解析 Linux 中的 VFS 文件系统机制(1)
  10. 毕业3年,我从鉴黄师转行到阿里做测试