class Life:
def __init__(self,name):
self.name=name
def __del__(self):
print "goodbye",self.name
brain=Life("lshaha")
brain="qwe" => out: goodbye lshaha
Python __del__
最新推荐文章于 2024-09-06 15:55:40 发布
class Life:
def __init__(self,name):
self.name=name
def __del__(self):
print "goodbye",self.name
brain=Life("lshaha")
brain="qwe" => out: goodbye lshaha