| S.__sizeof__() ->> |
| __sub__(...)
| x.__sub__(y) <==> x-y
|
| __xor__(...)
| x.__xor__(y) <==> x^y
|
| copy(...)
| Return a shallow copy of a set.
|
| difference(...)
| Return the difference of two or more sets as a new set.
|
| (i.e. all elements that are in this set but not the others.)
|
| intersection(...)
| Return the intersection of two or more sets as a new set.
|
| (i.e. elements that are common to all of the sets.)
|
| isdisjoint(...)
| Return True if two sets have a null intersection.
|
| issubset(...)
| Report whether another set contains this set.
|
| issuperset(...)
| Report whether this set contains another set.
|
| symmetric_difference(...)
| Return the symmetric difference of two sets as a new set.
|
| (i.e. all elements that are in exactly one of the sets.)
|
| union(...)
| Return the union of sets as a new set.
|
| (i.e. all elements that are in either set.)
|
| ----------------------------------------------------------------------
| Data and other attributes defined here:
|
| __new__ = <built-in method __new__ of type object>
| T.__new__(S, ...) -> a new object with type S, a subtype of T
class frozenset([iterable])
Return a new frozenset object, optionally with elements taken from iterable. frozenset is a built-in>
For other containers see the built-in set, list, tuple, and dict> 中文说明:
本函数是返回一个冻结的集合。所谓冻结就是这个集合不能再添加或删除任何集合里的元素。
它是不可变的,存在哈希值,好处是它可以作为字典的key,也可以作为其它集合的元素。缺点是一旦创建便不能更改,没有add,remove方法。
>>> y=[1,2,3,4,5,6,7,8,9]
>>> print(len(y),y)
(9, [1, 2, 3, 4, 5, 6, 7, 8, 9])
>>> set=frozenset(y)
>>> print(len(set),set)
(9, frozenset([1, 2, 3, 4, 5, 6, 7, 8, 9]))
>>> t=frozenset('bookshop')
>>> t
frozenset(['b', 'h', 'k', 'o', 'p', 's'])
>>> t=frozenset('bookshop')
>>> t
frozenset(['b', 'h', 'k', 'o', 'p', 's'])
>>> for i in t:
... print(i)
...
b
h
k
o
p
s