class Bike: compose = ['frame','wheel','pedal'] def __init__(self): self.other = 'basket' def use(self,time): print('you are {}m'.format(time*100)) class Share_bile(Bike): def cost(self,hour): print('you spent {}'.format(hour*2)) bike = Share_bile() print(bike.other) bike.cost(2)
输出:
basket
you spent 4