setpython
建立空集合 a=set()函數
轉化一個數據爲集合:set(obj), 注意數字不能直接轉化成集合,其餘均可以,只要是可迭代類型this
set(一個字典),則集合內元素爲字典的鍵值:spa
關鍵是集合內置了去重,交集,並集,差集,對稱差集函數,這是別的數據類型沒有的code
def
difference(
self
,
*
args,
*
*
kwargs):
# real signature unknown
"""
Return the difference of two or more sets as a new set. A中存在,B中不存在
(i.e. all elements that are in this set but not the others.)
"""
pass
def
difference_update(
self
,
*
args,
*
*
kwargs):
# real signature unknown
""" Remove all elements of another set from this set. 從當前集合中刪除和B中相同的元素"""
pass
def
discard(
self
,
*
args,
*
*
kwargs):
# real signature unknown
"""
Remove an element from a set if it is a member.
If the element is not a member, do nothing. 移除指定元素,不存在不保錯
"""
pass
def
intersection(
self
,
*
args,
*
*
kwargs):
# real signature unknown
"""
Return the intersection of two sets as a new set. 交集
(i.e. all elements that are in both sets.)
"""
pass
def
intersection_update(
self
,
*
args,
*
*
kwargs):
# real signature unknown
""" Update a set with the intersection of itself and another. 取交集並更更新到A中 """
pass
def
pop(
self
,
*
args,
*
*
kwargs):
# real signature unknown
"""
Remove and return an arbitrary set element.
Raises KeyError if the set is empty. 移除元素
"""
pass
def
remove(
self
,
*
args,
*
*
kwargs):
# real signature unknown
"""
Remove an element from a set; it must be a member.
If the element is not a member, raise a KeyError. 移除指定元素,不存在保錯
"""
pass
def
symmetric_difference(
self
,
*
args,
*
*
kwargs):
# real signature unknown
"""
Return the symmetric difference of two sets as a new set. 對稱差集,全部差集,A中有B中沒有+B中有A中沒
i.e. all elements that are in exactly one of the sets.)
"""
pass
def
symmetric_difference_update(
self
,
*
args,
*
*
kwargs):
# real signature unknown
""" Update a set with the symmetric difference of itself and another. 對稱差集,並更新到a中 """
pass
def
union(
self
,
*
args,
*
*
kwargs):
# real signature unknown
"""
Return the union of sets as a new set. 並集
(i.e. all elements that are in either set.)
"""
pass
def
update(
self
,
*
args,
*
*
kwargs):
# real signature unknown
""" Update a set with the union of itself and others. 更新 """
pass