擅长:python、mysql、java
<p>为什么不简单地使用<code>enumerate()</code>:</p>
<pre><code>site=urllib2.urlopen(r'http://www.rom.on.ca/en/join-us/jobs')
for i,j in enumerate(site):
if "http://www.ontario.ca" in j: #j is the line
print i+1 #i is the number start from 0 normally in the html code is 1 the first line so add +1
>>620
</code></pre>