擅长:python、mysql、java
<p>您可以使用<code>re.findall</code>函数将内容提取为</p>
<pre><code>file = open("/Users/shannonmcgregor/Desktop/npr.txt", 'r')
for line in file:
if re.search('<a href=[^>]*(islamic|praying|marines|comets|dyslexics)', line):
print re.findall(r'(?<=")[^"]*(?=")', line)[0]
</code></pre>
<p>将产生输出为</p>
^{pr2}$