擅长:python、mysql、java
<p>这里有一个简单的解决方案:</p>
<pre><code>import re
list1=['abc','oops','#exclude=10','exclude=java* kln*','smith','johns']
regex = re.compile('.*exclude.*')
okay_items = [x for x in list1 if not regex.match(x)]
print(okay_items)
</code></pre>
<p>在您的解决方案中,您使用了pop()并根据<a href="https://docs.python.org/2/tutorial/datastructures.html" rel="nofollow noreferrer">documentation</a></p>
<blockquote>
<p>list.pop([i]):</p>
<p>Remove the item at the given position in the list, and return it. If
no index is specified, a.pop() removes and returns the last item in
the list.</p>
</blockquote>