def collect(*args, **kwargs): # real signature unknown
Run the garbage collector.
从内存中释放超出作用范围的变量,不在使用的对象等,写此方法一般表示强制进行回收的,可能导致一些错误,建议不写为好
With no arguments, run a full collection.
The optional argument may be an integer specifying which generation to collect.
A ValueError is raised if the generation number is invalid. The number of unreachable objects is returned.
使用方法:
import gc gc.collect()
gc.collect()是要放在代码开头,还是跟着del变量的操作步骤之后??