1 >>> class PClass(object): 2 def setInfo(self,sex='Male'): 3 self.gender = sex 4 5 6 >>> class CClass(PClass): 7 def setInfo(self,who): 8 self.name = who 9 PClass.setInfo(self)#子类继承父类后想要扩展父类方法,若仍想保留父类方法可以通过回调 10 11 12 >>> x = CClass() 13 >>> x.setInfo('Tom') 14 >>> x.name 15 'Tom' 16 >>> x.gender 17 'Male'