#_*_coding:utf-8_*_ __author__='Wesley' class Vehicle: Country='China' def __init__(self,name,speed,load,power): self.name=name self.speed=speed self.load=load self.power=power def run(self): print("running") class SubWay(Vehicle): def __init__(self,name,speed,load,power,line): # Vehicle.__init__(self,name,speed,load,power) super(SubWay,self).__init__(name,speed,load,power) #使用父类方法初始化 self.line=line def run(self): print('di tie %s huan ying '%self.line) # Vehicle.run(self) #不知道self是谁,所以需要self 参数 super(SubWay,self).run() #调用父类的方法,self是line13,所以run不再需要self了,已经知道self是谁,没必要重复 line13=SubWay("CHina sub",'180lm','10000','dian',13) line13.run()