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

如何使用许多参数覆盖Python类的构造函数?

如何使用许多参数覆盖Python类的构造函数?

class Parent(object):
    def __init__(self, a, b):
        print 'a', a
        print 'b', b

class Child(Parent):
    def __init__(self, c, d, *args, **kwargs):
        print 'c', c
        print 'd', d
        super(Child, self).__init__(*args, **kwargs)

test = Child(1,2,3,4)

1例
第2天
3
b 4
python 2022/1/1 18:27:55 有192人围观

撰写回答


你尚未登录,登录后可以

和开发者交流问题的细节

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

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

请先登录

推荐问题


联系我
置顶