模拟银行(作者在小码王中学习到的)

本文介绍了模拟银行的实现,分别讨论了在V.001和V.100版本中如何使用文件夹保存银行信息,特别推荐使用Python原生IDLE以及VSCode作为开发环境。对于初学者,这两种工具提供了友好的编程体验。
摘要由CSDN通过智能技术生成

1.V.001

小马银行:使用文件夹保存当前信息,有记录

# 账户类
class Account():
    def __init__(self, name, password, balance, operation):
        self.name = name
        self.password = password
        self.balance = balance
        self.operation = operation
        print(self.name, "账户" + self.operation + "成功")

    # 查询余额
    def check(self):
        print("当前余额:", self.balance)

    # 存钱
    def save(self, money):
        self.balance += money
        self.operation = "存入" + str(money)

    # 取钱
    def withdraw(self, money):
        if money <= self.balance:
            self.balance -= money
            self.operation = "取出" + str(money)
        else:
            print("没钱还想来得瑟")

    # 记录
    def record(self):
        f = open(self.name + ".txt", "a")
        text = self.name + "," + 
  • 1
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值