python __del__自动回收

 对象消失或再无引用时自动调用__del__。


class Person:
    def __init__(self):
        print('init....')

    def __del__(self):
        print('对象内存回收了')


person = Person()
print('程序结束')

 (二)引用情况

猜你喜欢

转载自blog.csdn.net/sinat_38068807/article/details/86502409
今日推荐