您好, 欢迎来到 !    登录 | 注册 | | 设为首页 | 收藏本站

Python调用父方法多重继承

Python调用父方法多重继承

您可以使用__bases__这样的

class D(A, B, C):
    def foo(self):
        print("foo from D")
        for cls in D.__bases__:
            cls().foo("D")

进行此更改后,输出将为

foo from D
foo from A, call from D
foo from B, call from D
foo from C, call from D
python 2022/1/1 18:43:05 有378人围观

撰写回答


你尚未登录,登录后可以

和开发者交流问题的细节

关注并接收问题和回答的更新提醒

参与内容的编辑和改进,让解决方法与时俱进

请先登录

推荐问题


联系我
置顶