擅长:python、mysql、java
<p>在嵌套循环中,使用相同的变量<code>i</code>作为两个不同的东西。所以第一个被覆盖了。更改第二个变量名。在</p>
<p>理想情况下,像<code>i</code>这样的变量名不太具有描述性,很容易犯这样的错误。尝试类似于:</p>
<pre><code>for div in target_divs:
counties = div.find_all("div", class_= "table_cell_county")
for county in counties:
print county.text
print counties.index(county)
</code></pre>