修改属性:
可以在属性里加个函数:
def get_mileage(self):
print('the mileage is ' + str(self.mileage))
调动时:
car1.set_mileage(100)
再比如,增加里程:
def add_mileage(self,mileage):
if self.mileage >= 0:
self.mileage += mileage
修改属性:
可以在属性里加个函数:
def get_mileage(self):
print('the mileage is ' + str(self.mileage))
调动时:
car1.set_mileage(100)
再比如,增加里程:
def add_mileage(self,mileage):
if self.mileage >= 0:
self.mileage += mileage