class BankAccount:
def __init__(self,name,account,balance):
self.name = name
self.account = account
self.balance = balance
def __str__(self):
strBalance = str(self.balance)
msg = 'my name is'+' '+self.name + 'my account is'+' '+self.account +'my balance is' +' '+strBalance
return msg
def take(self,get):
self.balance = float(self.balance) - float(get)
return self.balance
def put(self,putin):
self.balance = float(self.balance) + float(putin)
return self.balance
myAccount = BankAccount('ye','zbao','67000')
myAccount.take(raw_input('how much do you want to take:'))
print 'my balance is:',myAccount.take
键入how much do you want to take:5000
输出为my balance is: <bound method BankAccount.take of <__main__.BankAccount instance at 0x0A1EC9B8>
|
|
|
|
|
共 2 个关于本帖的回复 最后回复于 2016-8-11 17:06