用python写atm自动取款_Python实现atm机的功能

阅读: 评论:0

2024年2月3日发(作者:)

用python写atm自动取款_Python实现atm机的功能

breakelse:print 'You choose {} is not in the shoplist!'.format(choice)shop()#查询余额功能def query_money():userInfo = (open('userinfo','rb'))totalmoney = userInfo[accountAuth][1]remaining = userInfo[accountAuth][2]print 'Your total money is {}, remaining money is 033[1;31m{}033[0m!'.format(totalmoney, remaining)#存钱功能def save_money():while 1:save_desc = raw_input("Please describe save money the details:").strip()if len(save_desc) == 0:continuetry:save_money = int(raw_input("Please save the money:"))except ValueError:print "033[;31mYou entered must be number.033[0m"save_money()if save_money % 100 != 0:print 'You must enter an integer of 100!'continueuserInfo = (open('userinfo', 'rb'))remaining = int(userInfo[accountAuth][2]) + save_moneyuserInfo[accountAuth][2] = (userInfo, open('userinfo', 'wb'))print 'Your total money is %s, your remaining is 033[;31m%s033[0m!' %(userInfo[accountAuth][1],userInfo[accountAuth][2])Bill(accountAuth,me("%Y-%m-%d %H:%M:%S"),save_desc,"+%d" % float(save_money))next = raw_input("ue nPlease select: ").strip()if next == '1':continue

elif next == '2':list()elif next == '3':exit()else:print 'Please enter the correct content!'#取钱功能def draw_money():while 1:draw_desc = raw_input("Please describe draw money the details:").strip()if len(draw_desc) == 0:continuetry:draw_money = int(raw_input("Please draw the money:"))except ValueError:print "033[;31mYou entered must be number.033[0m"draw_money()if draw_money % 100 != 0:print 'You must enter an integer of 100!'continueuserInfo = (open('userinfo', 'rb'))#There are bugs here!if draw_money > int(userInfo[accountAuth][2]):print '033[;31mYour remaining is insufficient!033[0m'list()userInfo = (open('userinfo', 'rb'))remaining = int(userInfo[accountAuth][2]) - draw_money - draw_money * 0.05userInfo[accountAuth][2] = (userInfo, open('userinfo', 'wb'))print 'Your total money is %s, your remaining is 033[;31m%s033[0m!' %(userInfo[accountAuth][1],userInfo[accountAuth][2])Bill(accountAuth,me("%Y-%m-%d %H:%M:%S"),draw_desc,"+%d" % float(draw_money))next = raw_input("ue nPlease select: ").strip()if next == '1':

if next == '1':continueelif next == '2':list()elif next == '3':exit()else:print 'Please enter the correct content!'#账单功能def query_bill():Income = []Spending = []num = 0print "AccountttTimettDescriptiontt RMB"with open('bill', 'rb') as f:while True:try:line = (f)if line["Account"] == accountAuth:if '+' in line["RMB"]:print "033[;33m%rt%rt%rttt%r033[0m" % (line["Account"],line["Time"],line["Description"],line["RMB"])income = line["RMB"].strip("+")(income)else:print "%rt%rt%rttt%r" % (line["Account"],line["Time"],line["Description"],line["RMB"])spending = line["RMB"].strip("-")(spending)except:breakfor i in Income:num = num + int(i)income = numprint "Income is %r" % numfor i in Spending:

num = num + int(i)spending = numprint "Spending is %r" % numprint "Total is %r" % (int(income) + int(spending))#修改密码功能def modify_passwd():userInfo = (open('userinfo', 'rb'))old_passwd = raw_input("Please enter old password:").strip()while 1:if old_passwd == userInfo[accountAuth][0]:new_passwd = raw_input("Please enter new password:").strip()if len(new_passwd) < 6:print 'Your password is too simple!'continueconfirm_new_password = raw_input("Please confirm new password again:").strip()if new_passwd != confirm_new_password:print 'Two passwords do not match!'else:userInfo[accountAuth][0] = confirm_new_(userInfo, open('userinfo', 'wb'))print '033[;32mYour password is changed successful!033[0m'exit()else:print 'Your password is error!'modify_passwd()#ATM机所有功能def list():print '''033[;32m#################################################### welcome to ATM! ## ## money ## money money ## er money bill #

exit()for num in range(3,0,-1):passwdAuth = raw_input("Please input user password:").strip()if len(passwdAuth) == 0:continueif passwdAuth == userInfo[accountAuth][0]:list()else:print "Wrong password, Can try again 033[;31m%r033[0m itmes" % numcontinueelse:lockaccount = userInfo[accountAuth]('lock')(userInfo,open('userinfo', 'wb'))print "033[;31mAccount freeze within 24 hours033[0m"exit()else:print "033[;31mWrong account %r,retype033[0m" % accountAuth2.商品表[root@python atm]# cat puter 6000iphone 5000mouse 250keyboard 40camera 8000package 500power 2303.初始化账号密码[root@python atm]# cat create_#!/usr/bin/env python# -*- coding: utf-8 -*-import pickleuserInfo = {'xtd':['123456','150000','150000'],'bob':['666','8000','8000'],'xdg':['888','3000','3000']}

Your total money is 8000, remaining money is 1000!Please choose according to your needs:6.流程图

用python写atm自动取款_Python实现atm机的功能

本文发布于:2024-02-03 11:35:22,感谢您对本站的认可!

本文链接:https://www.4u4v.net/it/170693132250261.html

版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。

标签:功能   实现   自动   取款   查询   密码   余额   修改
留言与评论(共有 0 条评论)
   
验证码:
排行榜

Copyright ©2019-2022 Comsenz Inc.Powered by ©

网站地图1 网站地图2 网站地图3 网站地图4 网站地图5 网站地图6 网站地图7 网站地图8 网站地图9 网站地图10 网站地图11 网站地图12 网站地图13 网站地图14 网站地图15 网站地图16 网站地图17 网站地图18 网站地图19 网站地图20 网站地图21 网站地图22/a> 网站地图23