python 3.x中子类的继承父类的相关方法和属性:
class Parent(object):
def parentMethod(self):
print('calling parent method')
class Child(Parent):
def childMethod(self):
print('calling child method')
p = Parent()
p.parentMethod()
c = Child()
c.childMethod()
c.parentMethod()
运行结果:
calling parent method
calling child method
calling parent method