1. 程式人生 > >Python __析構方法__del__

Python __析構方法__del__

對象 python int self sel __init__ clas __del__ ini

class Foo:
def __init__(self,x):
self.x=x

def __del__(self): #在對象資源被釋放時觸發
print(‘-----del------‘)
print(self)

f=Foo(100000)
del f
print(‘=======================>‘)

Python __析構方法__del__