admin管理员组文章数量:1647999
所以,我用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”
版权声明:本文标题:python中account是啥_如何在python中实现account类的传输方法 内容由热心网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:https://m.elefans.com/dongtai/1729495192a1202825.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论