嘿伙计们,所以我在运行此代码时收到此“TypeError:'int' object is not callable”错误,我做了一些研究,我认为这与我的变量命名有关?有人可以向我解释什么是错的吗?
class account(object):
def set(self, bal):
self.balance = bal
def balance(self):
return balance
这是我的示例运行:
>>> a = account()
>>> a.set(50)
>>> a.balance()
Traceback (most recent call last):
File "<pyshell#12>", line 1, in <module>
a.balance()
TypeError: 'int' object is not callable