class MyObject(object): def __int__(self): self.x=9 def power(self): return self.x*self.x obj=MyObject() print(hasattr(obj,'x'))
创建对象了为啥hasattr还是显示的是错误
单词拼错了,应该是__init__
__init__