#1.定义类:含有参数init;实例方法
class Car():
def init(self,color,weight):
self.color = color
self.weight = weight
def print_info(self):
print(f’猫的颜色是{self.color},猫的重量是{self.weight}kg’)
#调用实例
tom = Car(‘黑色’,2)
tom.print_info()
tom2 = Car(‘白色’,2.5)
tom2.print_info()