zoukankan      html  css  js  c++  java
  • Python类的继承顺序__mro__

    class A:
        def test(self):
            print('print from A')
        pass
    
    class B(A):
        # def test(self):
        #     print('print from B')
        pass
    
    class C(A):
        def test(self):
            print('print from C')
        pass
    
    class D(B):
        # def test(self):
        #     print('print from D')
        pass
    
    class E(C):
        # def test(self):
        #     print('print from E')
        pass
    
    class F(D,E):
        # def test(self):
        #     print('print from F')
        pass
    
    f=F()
    print(F.__mro__)
    f.test()
    输出:
    class A:
        def test(self):
            print('print from A')
        pass
    
    class B(A):
        # def test(self):
        #     print('print from B')
        pass
    
    class C(A):
        def test(self):
            print('print from C')
        pass
    
    class D(B):
        # def test(self):
        #     print('print from D')
        pass
    
    class E(C):
        # def test(self):
        #     print('print from E')
        pass
    
    class F(D,E):
        # def test(self):
        #     print('print from F')
        pass
    
    f=F()
    print(F.__mro__)
    f.test()
    
    写入自己的博客中才能记得长久
  • 相关阅读:
    bootstrap
    移动视口,以及适配
    CSS线性渐变
    css之什么是bfc
    css 深入进阶之定位和浮动三栏布局
    webpack 4 技术点记录
    jQuery的学习总结
    jQuery 知识大全
    JS高级进阶
    正则
  • 原文地址:https://www.cnblogs.com/heris/p/14764627.html
Copyright © 2011-2022 走看看