class A:
def test(self):
print("A --- test")
def demo(self):
print("A --- demo")
class B:
def test(self):
print("B --- test")
def demo(self):
print("B --- demo")
"""
多继承语法
class 子类名(父类名1, 父类名2, ...)
"""
class C(A, B):
"""
多继承可以让子类对象,同时具有多个父类的属性和方法
"""
pass
c = C()
c.test()
c.demo()
# 确认C类对象调用方法的顺序
# method resolution order
print(C.__mro__)
python多继承注意事项
最新推荐文章于 2022-07-14 14:34:13 发布