定義:
在對象馬上銷毀前,就是銷毀前最后做的事情
實例:
class Foo: def __init__(self,x): self.x=x def __del__(self): #在對象資源被釋放時觸發 print('-----del------') print(self) f=Foo(100000) del f print('=======================>')
在對象馬上銷毀前,就是銷毀前最后做的事情
class Foo: def __init__(self,x): self.x=x def __del__(self): #在對象資源被釋放時觸發 print('-----del------') print(self) f=Foo(100000) del f print('=======================>')
本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。