【发布时间】:2018-12-01 15:02:30
【问题描述】:
我在 python 多级类继承中遇到错误。
这是我的代码:
class Animal():
def __init__(self):
print("Animal created")
def whoAmI(self):
print("Animal")
def eat(self):
print('eating')
class Dog(Animal):
print("dog created")
class Cat(Dog):
print("car created")
m = Cat()
Cat.eat()
这是我得到的错误:
【问题讨论】:
-
我认为你的意思是让你的 Cat 类继承自 Animal,而不是 Dog
-
@Planet 我的回答对你有帮助吗?
-
@TobiasWilfert thnks 它帮助了我!
-
接受@TobiasWilfert
标签: python class inheritance compiler-errors multi-level