擅长:python、mysql、java
<p>我不太确定你说的对不对,但请看一看并发表评论:</p>
<pre><code>k = 42 #whatever
triplets = {k: [[1, 3, 15], [1, 3, 13], [1, 3, 11], [1, 3, 9], [1, 3, 8], [1, 3, 5], [1, 4, 15]]}
cset1 = {k: [set([5])]}
cset2 = {k: [{1, 8}, {1, 9}, {1, 11}]} #changed this to sets
triplets[k] = [x for x in triplets[k] if
all (y - set(x) for y in cset1[k]) and
all (y - set(x) for y in cset2[k])
]
print(triplets[k])
</code></pre>