您的位置:首页技术文章
文章详情页

python - 为什么__del__不执行呢?

【字号: 日期:2022-08-08 18:17:16浏览:49作者:猪猪

问题描述

新手用python2.7写的一个scrapy爬虫,希望爬虫退出去的时候清理打开的firefox进程,发现不管用,请帮忙看下,为什么最下面的self.browser.quit不执行呢

def __init__(self):self.browser = webdriver.Firefox() def __del__(self):self.browser.quit()

问题解答

回答1:

def spider_closed(self, spider): dosomething()

似乎在scrapy中会建议你这么做scrapy: Call a function when a spider quits

标签: Python 编程
相关文章: