class A(object):
    def getName(self):
        print("name is A")

class B(object):
    def getName(self):
        print("name is B")

class C(A, B):
    def __init__(self):
        print("class is C")
c = C()
c.getName()


class D(B, A):
    def __init__(self):
        print("class is D")
d = D()
d.getName()

执行结果为:

"D:\Program Files\python3.6.7\python.exe" D:/pythonWorkspace/untitled1019/test/test1.py
class is C
name is A
class is D
name is B

Process finished with exit code 0

 

相关文章:

  • 2021-05-24
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-11-24
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2022-12-23
  • 2021-11-20
  • 2021-12-08
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-06-21
相关资源
相似解决方案