擅长:python、mysql、java
<p>在这种情况下,只需将iterable转换为<strong>集</strong>:</p>
<pre><code> for i in set(soup.find_all("div",{"class":"bg lazy-image"})):
print(i.get("data-src"))
</code></pre>
<p>这样,iterable<strong>中的所有重复项都将被删除</p>
<p>我强烈建议大家阅读Python的数据结构:</p>
<p><a href="https://docs.python.org/3/tutorial/datastructures.html" rel="nofollow noreferrer">https://docs.python.org/3/tutorial/datastructures.html</a></p>