###Python 类的继承###
class Bike:
compose = ['frame','wheel','padal']
def __init__(self):
self.other = 'basket' #定义实例属性
def use(self,time):
print('you are rid {}m'.format(time*100))
class Share_bike(Bike):
def cost(self,hour):
print('you spent {}'.format(hour*2))
bike = Share_bike()
print(bike.other)
bike.cost(2)
#在新类Share_bike后面的括号中加入了Bike,表示Share_bike继承了Bike父类.父类的变量和方法可以完全被子类继承,在特殊情况下,也可以对其进行覆盖.