class Bird:
def _init_(self):
self.hungry=True
def eat(self):
if self.hungry:
print('Aaah...')
self.hungry=False
else:
print('No Thanks...')
然后调用 b=Bird()
b.eat()
为什么会提示这样的错误呢?
Traceback (most recent call last):
File "
b.eat()
File "
if self.hungry:
AttributeError: 'Bird' object has no attribute 'hungry'