蔡森冉815
2018-04-17 17:26
TypeError: 'NoneType' object is not callable
class Programer(object):
hobby = "Play Computer"
def __init__(self,name,age,weight):
self.name = name
self._age = age
self.__weight = weight
@classmethod
def get_hobby(cls):
return cls.hobby
@property
def get_infor(self):
print("my name is hh")
def get_weight(self):
return self.__weight
class BackenProgramer(Programer):
def __init__(self,name,age,weight,languge):
super(BackenProgramer,self).__init__(name,age,weight)
self.languge = languge
def get_infor(self):
print("hh is my name")
def intudece(programer):
if isinstance(programer,Programer):
programer.get_infor()
if __name__=="__main__":
programer = Programer('Alb',28,90)
bcprogramer = BackenProgramer('Alber',25,80,'python')
#print (dir(programer))
#print (programer.__dict__)
#print (BackenProgramer.get_hobby())
#programer.get_infor
#print (isinstance(programer,Programer))
intudece(programer)
bcprogramer.get_infor
29行,去掉“()”;42行,加上“()”
intudece(programer),相当于调用的是@property后面的方法,需要以参数的形式调用
bcprogramer.get_infor,调用的是重写后的get_infor,并没有用@propery装饰器,所以需要加()
29行,去掉最后的“()”
Python-面向对象
71226 学习 · 83 问题
相似问题