1. # 与文件类似 每个对象都会占用系统一部分内存,使用之后如果不及时销毁,会浪费系统资源。
    2. # 系统销毁对象后 收回对象所占用内存空间
    3. class Car:
    4. def __init__(self):
    5. self.color = "红色"
    6. print("对象被创建")
    7. def __del__(self):
    8. print("对象被销毁")
    9. car = Car()
    10. print(car.color)
    11. del car
    12. print(Car.color)