在scrapy 1.3中,yield request和return request有什么区别? [英] In scrapy 1.3, what is the difference between a yield request and a return request?
本文介绍了在scrapy 1.3中,yield request和return request有什么区别?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
似乎他们提供了相同的功能,最终通过管道或提要返回一个字典或项目.有什么理由让我使用一个而不是另一个吗?
It seems they are providing the same function, ultimately returning a dict or item through a pipeline or feed. Is there a reason I would use one over the other?
推荐答案
与return"相反,yield"不退出函数并继续用你的 for 循环.如果您使用return",则您的 for 循环将在第一次迭代后完成.
In contrast to "return", "yield" doesn't exit the function and continues with the your for-loop. If you use "return", your for-loop will finish after the first iteration.
欲了解更多信息:什么是产量"?Python 中的关键字 do?
这篇关于在scrapy 1.3中,yield request和return request有什么区别?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文