我已经搞乱了参数和一般的类,但我仍然无法让它工作。即使我删除self.v3
了我需要的,我也会得到None
第二个输出......
class Base(object):
def __init__(self, v1, v2):
self.v1 = v1
self.v2 = v2
def together(self):
return self.v1 + self.v2
class Sub1(Base):
def __init__(self, v1, v2, v3):
super(Sub1, self).__init__(v1, v2)
self.v3 = v3
def together(self):
super(Sub1, self).together() + self.v3
b1 = Base(1,2)
print b1.together()
s1 = Sub1(3,2,1)
print s1.together()
输出:3, 6