class Account:
def __init__(self, initial):
self.balance = initial
def deposit(self, amt):
self.balance = self.balance + amt
def withdraw(self,amt):
self.balance = self.balance - amt
def getbalance(self):
return self.balance
a = Account(1000.00)
a.deposit(550.23)
a.deposit(100)
a.withdraw(50)
print a.getbalance()
我得到這個錯誤,當我運行此代碼.. AttributeError的:帳戶實例沒有屬性「存款」AttributeError幫助!
您的縮進是錯誤的。 – 2010-06-12 02:20:05