- 帖子
- 7
- 精华
- 0
- 积分
- 40
- 阅读权限
- 10
- 注册时间
- 2017-11-9
- 最后登录
- 2018-1-31
|
class Vehicle(object):
def __init__(self,speed):
self.speed = speed
class Car(Vehicle):
def __init__(self, speed, distance, oil_spent):
Vehicle.__init__ = speed
self.distance = distance
self.oil_spent = oil_spent
def cost(self):
f = self.distance * self.oil_spent
print('we need %s fuels' %f)
class Bike(Vehicle):
pass
bike = Bike(40)
car = Car(80,100,0.012)
print(car.cost)
我是自己写的,为什么我只能查到一大串内存值,像这样:
<bound method Car.cost of <__main__.Car object at 0x0173ABD0>> |
|