
本文共 1838 字,大约阅读时间需要 6 分钟。
<Class(Class): ������������������������������������������������������������������������������������������������������������������������>
<������(Instance): ���������������������������>
<������(Methods): ������������������������>
<������������
<���������������������������������������������__init__()������������������������������������������������������������������>
<���������self���������������������������������������������������������������������������������������������������������������������������������>
<���self���������������������������������������������������������������������>
<���������������������������������������������������������������������������������������>
<���������������������������������������������������������������������������������������������������������������������������������������������������>
<������������super()���������������������������������>
<���������������������������������������������������������������������������������������������������������������������������������������������������������������������
class Car: def init(self, make, model, year): self.ma = make self.mod = model self.ye = year self.gas = 100
def get_descriptive_name(self): long_name = f"{self.ye} {self.ma} {self.mod}" return long_name.title()def fill_gas_tank(self): print(f"The tank is only {self.gas} gas")
class ElectricCar(Car): def init(self, make, model, year): super().init(make, model, year) def fill_gas_tank(self): print("This car doesn't need a gas tank!")
my_car = ElectricCar('teals', 'model s', 2020) my_car.fill_gas_tank()
car = Car('audi', 'A8L', 2021) car.fill_gas_tank()
���������������Uh������������������������������
<���������������������������:>
������������������������������������������������������������������������������������������������������������������������������������
发表评论
最新留言
关于作者
