python-类的继承(学习)
代码里用到了
1.类的定义
2.子类继承父类
(1)如何重新定义子类的__init__()方法;
class BenzCar:
brand='奔驰'
@staticmethod #定义类的方法
def pressHorn()
print("嘟嘟~~")
def __init__(self,color,engineSN):
self.color=color
self.engineSN=engineSN
def change(self,newColor): #定义实例的方法
self.
原创
2022-05-01 16:57:38 ·
719 阅读 ·
0 评论