擅长:python、mysql、java
<p>Python有一个<em>垃圾收集器</em>,因此当没有更多的引用指向对象时,会从内存中删除该对象。
关键字<code>del</code>只是删除变量名和对象之间的绑定(引用)。如果不再引用该对象,则垃圾回收器将释放其内存。
使用<code>del</code>删除对象内部的对象是没有意义的,因为<code>del</code>本身不会触发任何删除。在</p>
<p>此外,在您的代码中有一个语法错误,实际上没有定义变量<code>obj</code>。您应该使用<code>self</code>从其中引用对象本身。在</p>