Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我有一个列表[(12,12),(1,23),(43,12)] ,如何从该列表中删除这些元素:
[(12,12),(1,23),(43,12)]
[(12,12),(1,23),(43,12),(2,1),(1,3),(43,1)]
所以这个列表变成了
[(2,1),(1,3),(43,1)]
然后随机选择其中两个放入另一个列表
import random a = [(12,12),(1,23),(43,12),(2,1),(1,3),(43,1)] b = [(12,12),(1,23),(43,12)] c = random.sample(set(a) - set(b), 2)