zoukankan      html  css  js  c++  java
  • python同时继承多个类且方法相同

    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 Filespython3.6.7python.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
  • 相关阅读:
    Jenkins 插件管理
    持续集成 目录
    gitlab 目录
    jenkins 目录
    POJ 2828
    POJ 2782
    POJ 2725
    POJ 2769
    POJ 2739
    POJ 2707
  • 原文地址:https://www.cnblogs.com/harryTree/p/11804747.html
Copyright © 2011-2022 走看看