擅长:python、mysql、java
<p>您可以直接提取图像<code>src</code></p>
<pre><code>>>> images = ['<img src="demo.jpg" height=12>', '<img src="demo2.jpg" height=500>']
>>> for image in images:
print(re.search(r'<img[^>]*src="([^"]*)"', image).group(1))
demo.jpg
demo2.jpg
</code></pre>
<p>如果您的输入都是<code>string</code>,您可以使用<code>findall</code>,然后对其进行迭代</p>
<pre><code>>>> images = '''<img src="demo.jog" height=12> <img src="demo.jog" height=500>'''
>>> res = re.findall(r'<img[^>]*src="([^"]*)"', images)
>>> for img in res:
print(img)
demo.jpg
demo2.jpg
</code></pre>