python中的简单银行帐户

时间:2019-04-04 10:38:44

标签: python-3.x

我如何创建一个保存和更新事务的功能,使得当我关闭程序并再次运行它时,帐户将显示程序结束前进行的最后一笔事务。

Account(object):

    def __init__(self):
        self.balance = 0

    def deposit(self, amount):
        if (amount < 0):
            return 'Please deposit an amount greater than 0'
            self.balance += amount
            print ('Amount deposited {}'.format(amount))
            return 'SUCCESS'

    def withdraw(self, amount):
        if (amount < 0):
            return 'Please withdraw an amount greater than 0'
        if (amount > self.balance):
    return

0 个答案:

没有答案