Python之set方法
class set(object):
"""
set() -> new empty set object
set(iterable) -> new set object
"""
def add(self, *args, **kwargs): # 添加元素
"""
Add an element to a set,
This has no effect if the element is already present.
"""
def clear(self, *args, **kwargs): # 清除内容
""" Remove all elements from this set. """
def copy(self, *args, **kwargs): # 浅拷贝,只复制地址空间第一层。
""" Return a shallow copy of a set. """
def difference(self, *args, **kwargs): # A中存在,B中不存在,并将其赋值给新值。
"""
Return the difference of two or more sets as a new set.
"""
def difference_update(self, *args, **kwargs): # 从当前集合中删除和B中相同的元素,并更新自己。
""" Remove all elements of another set from this set."""
def discard(self, *args, **kwargs): # 移除指定元素,不存在不会报错。
"""
Remove an element from a set if it is a member.
If the element is not a member, do nothing.
"""
def intersection(self, *args, **kwargs): #取交集
"""
Return the intersection of two sets as a new set.
(i.e. all elements that are in both sets.)
"""
def intersection_update(self, *args, **kwargs): # 取交集并更新到A。
""" Update a set with the intersection of itself and another. """
def isdisjoint(self, *args, **kwargs): # real signature unknown
""" Return True if two sets have a null intersection. 如果没有交集,返回True,否则返回False"""
def issubset(self, *args, **kwargs): # A是否是B子序列
""" Report whether another set contains this set."""
def issuperset(self, *args, **kwargs): # A是否是B父序列
""" Report whether this set contains another set."""
def pop(self, *args, **kwargs): # 移除元素
"""
Remove and return an arbitrary set element.
Raises KeyError if the set is empty.
"""
def remove(self, *args, **kwargs): # 移除指定元素,不存在会报错。
"""
Remove an element from a set; it must be a member.
If the element is not a member, raise a KeyError.
"""
def symmetric_difference(self, *args, **kwargs): # 对称差集
"""
Return the symmetric difference of two sets as a new set.
(i.e. all elements that are in exactly one of the sets.)
"""
def symmetric_difference_update(self, *args, **kwargs): # 对称差集,并更新到A中
""" Update a set with the symmetric difference of itself and another."""
def union(self, *args, **kwargs): # 并集
"""
Return the union of sets as a new set.
(i.e. all elements that are in either set.)
"""
def update(self, *args, **kwargs): # 更新元素
""" Update a set with the union of itself and others."""
posted on 2018-02-06 20:08 大道至简,规则无上。 阅读(162) 评论(0) 收藏 举报
浙公网安备 33010602011771号