我正在查看此示例-Can someone explain me in detail how this code works regarding (Using Python to Access Web Data),并且对代码中count = 0的最后一行之一有疑问
任何人都可以解释为什么需要它吗?如果可能,@ chitown88是否可以帮助您参与此线程?
if count == position: #<------- and the variable to get the position
url = tag.get('href', None)
print("Retrieving:" , url)
count = 0 <----------------------------------------this line
break
谢谢
答案 0 :(得分:1)
...
count = 0 # <-- Must reset this value.
...
while n < numbers:
...
for tag in tags:
...
if count == position:
...
count = 0 # <-- Resetting this value before the next for-loop.
break # <-- This breaks out of the for-loop, going back into the while-loop