2014-03-04 82 views

回答

4

轉換您的集來frozenset() objects

set(frozenset(s) for s in A) 

一個frozenset()是不可變集對象,更重要的是,哈希的。因此它可以存儲在set()中。

演示:

>>> A = [set([1,2]),set([1,2]), set([1])] 
>>> set(frozenset(s) for s in A) 
set([frozenset([1, 2]), frozenset([1])]) 
相關問題