class Car():
def init(self,make,model,year):
self.make = make
self.model = model
self.year = year
self.odometer_reading = 0
def get_descriptive_name(self):
long_name = str(self.year ) + ' ' + self.make + ' ' +self.model
return long_name.title()
def read_odometer(self):
print("This car has " + str(self.odometer_reading)
+ " miles on it .")
def updat_odometer(self,mileage):
self.odomter_reading = mileage
my_new_car = Car('audi','a4','2016')
print(my_new_car.get_descriptive_name())
my_new_car.updat_odometer(23) ''''这里实参!放入无反应''
my_new_car.read_odometer()
如果我把 my_new_car.odometer_reading = 23 通过直接修改,不调用updat-odometer()函数就可以生成
This car has 23 miles on it
请问这是为什么?
def 定义函数的位置我改过了了 却没有反应 以下为书上内容