#定义一个汽车类(Car),属性有颜色,品牌,车牌号,价格,并实例化两个对象,给属性赋值,并输入属性值。
#比如:属性:“红色”,”奔驰“,”黑A00000“,15000000
class Car():
def __init__(self,color,brand,plate,price):
self.color=color
self.brand=brand
self.plate=plate
self.price=price
def driver(self):#这里输出
print(self.color,self.brand,self.plate,self.price)
c=Car("红色","奔驰","闽C00000",15000000)
c.driver()
运行结果如下: