class Car(object):
def __init__(self,newWheelNuw,newColor):
self.newWheelNuw=newWheelNuw
self.newColor=newColor
def run(self):
print('车在跑,目标:厦威夷')
def __del__(self):
print('---析构方法被调用--')
BMW=Car('newWheelNuw','newColor')
BMW.run()
del BMW
try:
print(isinstance(BMW,Car))
except NameError as e:
print(e)
输出结果:
车在跑,目标:厦威夷
---析构方法被调用--
name 'BMW' is not defined
[Finished in 0.3s]