admin管理员组

文章数量:1648001

所以,我用python创建了一个Account类。它的基本功能是存款、取款和结存。但我在传输方法上遇到了麻烦。

这是我的代码(抱歉代码转储):class Account:

"""simple account balance of bank"""

def __init__ (self, name, balance):

self.name = name

self.balance = balance

print('Account of ' + self.name)

def deposit(self, amount):

if amount > 0:

self.balance += amount

self.statement()

def withdrawal(self, amount):

if amount > 0 and self.balance > amount:

self.balance -= amount

self.statement()

else:

print("the ammount in your is not sufficent")

self.statement()

def statement(self):

print("Hi {} your current balance is {}".format(self.name,self.balance))

def transfer(self, amount, name):

self.balance = self.balance - amount

name.balance = name.balance + amount

return name.balance()

现在,它适用于

^{pr2}$

那么如何运行以下代码:siddharth.transfer(11, "abc")

siddharth.transfer(11, Account.abc)

另外,如果帐户“abc”不存在,如何创建帐户“abc”

本文标签: 方法如何在PythonAccount