擅长:python、mysql、java
<pre><code>>>> strings = ['30 brown bears', '30 brown foxes', '20 green turtles', '10 brown dogs']
>>> conditions = [('brown', True), ('bear', False), ('dog', False)]
>>> for text in strings:
if all((x in text) == c for x,c in conditions):
print text
30 brown foxes
</code></pre>