关于文章中链接的示例中的python抓取的问题
我正在回顾这个示例,对代码中最后一行的计数=0有一个问题 谁能解释一下为什么它需要在那里?如果可能的话,@chitown88你能帮忙吗,因为你参与了这个帖子关于文章中链接的示例中的python抓取的问题,python,Python,我正在回顾这个示例,对代码中最后一行的计数=0有一个问题 谁能解释一下为什么它需要在那里?如果可能的话,@chitown88你能帮忙吗,因为你参与了这个帖子 if count == position: #<------- and the variable to get the position url = tag.get('href', None) print("Retrieving:" , url) count = 0 <
if count == position: #<------- and the variable to get the position
url = tag.get('href', None)
print("Retrieving:" , url)
count = 0 <----------------------------------------this line
break
如果计数==位置:#。。。
count=0#由于count
是在while
循环之外声明的,因此在中断for
的内部循环之前,代码会在while
循环的下一次迭代中将count
变量重置为0
。感谢您的澄清。我理解代码在切换到下一个url后需要重新计数。有道理。