擅长:python、mysql、java
<p>要检查成员身份,可以使用<code>any()</code>或<code>not any()</code></p>
<pre><code>x=[['e', 'h', 'c', 'w'], ['p', 'j'], ['w', 's', 'u']]
y=['k', 'w']
def non_intersecting(l1, l2):
outlist=[]
for sublist in x:
if not any([elem in sublist for elem in y]):
outlist.append(sublist)
return outlist
non_intersecting(x, y)
[['p', 'j']]
</code></pre>
<p>以上也可以简化为一个列表</p>
<pre><code>def non_intersecting(l1, l2):
return [i for i in x if not any([j in i for j in y])]
</code></pre>