python入门之ATM机程序练习

本文介绍了一位Python初学者通过编写ATM机模拟程序进行学习的经验,提供了详细的参考代码链接,旨在帮助读者理解基础的Python编程概念。
摘要由CSDN通过智能技术生成
功能:
1.额度:8000
2.可以提现,手续费5%
3.每月最后一天出账单,写入文件
4.记录每月日常消费流水
5.提供还款接口

此代码在python3.X上面运行
主程序 atm.py
import time
import pickle
import sys
import os

#定义账单和购物车
Bill = {}
products = {}
shoplist = []

#define Bill function, used to record billing details(account/time/describe/money).

def Bill(Account,Time,Description,RMB):
    Bill= {"Account":Account,"Time":Time,"Description":Description,"RMB":RMB}
    #用pickle模块把账单信息存到bill文件中去
    pickle.dump(Bill,open("bill","ab"))

#-----------------------------------------------------------------------------------------------------
#购物功能
def shop():
    print( '\033[;32mWelcome to shopping!\n\033[0m')
    with open('shops') as f:
        for line in f.readlines():
            print('{}'.format(line.strip()))
    while 1:
        with open('shops') as f:
            for line in f.readlines():
                line = line.strip()
                commodity = line.split()[0]
                price = line.split()[1]
                products[commodity] = price
            choice = input("\033[;32mPlease input you want to buy>>\033[0m").strip()
            if len(choice) == 0:
                continue
            elif choice == 'back':
                list()
            if choice in products:
                remaining = pickle.load(open('userinfo','rb'))
                if int(products[choice])>int(remaining[accountAuth][2]):
                    print("In your card remaining sum already insufficiency, please prompt sufficient value!'")
                else:
                    while 1:
                        shoplist.append(choice)
                        new_remaining = int(int(remaining[accountAuth][2]
  • 1
    点赞
  • 7
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值