set()集合基本操做

運用頻次:☆☆this

set是一個無序且不重複元素集,基本操做以下:spa

1. 建立set集合,會自動轉換成set類型3d

2. add():添加元素code

 def add(self, *args, **kwargs): # real signature unknown
       # 添加元素
        """
        Add an element to a set.
        
        This has no effect if the element is already present.
        """
        pass

3. clear():清除元素blog

 def clear(self, *args, **kwargs): # real signature unknown
        #清除元素
        """ Remove all elements from this set. """
        pass

3. copy():淺拷貝element

def copy(self, *args, **kwargs): # real signature unknown
        """ Return a shallow copy of a set. """
        pass

 4. difference():取差集,不更新原集合rem

def difference(self, *args, **kwargs): # real signature unknown
       # 取差集,不更新原集合,從新生成新的集合
        """
        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.)
        """
        pass

 5. difference_update():取差集,更新原集合it

def difference_update(self, *args, **kwargs): # real signature unknown
       # 取差集,更新原集合,不生成新的集合
        """ Remove all elements of another set from this set. """
        pass

 6. discard():刪除元素,更新原集合io

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

 7. intersection():取交集,返回一個新的集合class

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

 8. intersection_update():取交集,更新原集合

def intersection_update(self, *args, **kwargs): # real signature unknown
      # 取交集,更新原集合
        """ Update a set with the intersection of itself and another. """
        pass

 9. isdisjoint():判斷是否有交集,無則返回True

def isdisjoint(self, *args, **kwargs): # real signature unknown
       # 若無交集,則返回True
        """ Return True if two sets have a null intersection. """
        pass

 10. issubset():判斷是不是子集,是則返回True

def issubset(self, *args, **kwargs): # real signature unknown
       # 判斷另外一集合是否包含該集合,是則返回True
        """ Report whether another set contains this set. """
        pass

 11. issuperset():判斷是不是父集,是則返回True

def issuperset(self, *args, **kwargs): # real signature unknown
       # 判斷該集合是否包含另外一集合,是則返回True
        """ Report whether this set contains another set. """
        pass

 12. pop():隨機刪除一個元素並返回,更新原集合

def pop(self, *args, **kwargs): # real signature unknown
       # 隨機刪除一個元素並返回,更新原集合
        """
        Remove and return an arbitrary set element.
        Raises KeyError if the set is empty.
        """
        pass

 13. remove():刪除元素,更新原集合

 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

 14. symmetric_difference():取差集,不更新原集合

 def symmetric_difference(self, *args, **kwargs): # real signature unknown
      # 取差集,返回一個新的集合,不更新原集合
        """
        Return the symmetric difference of two sets as a new set.
        
        (i.e. all elements that are in exactly one of the sets.)
        """
        pass

 15. symmetric_difference_update():取差集,更新原集合

 def symmetric_difference_update(self, *args, **kwargs): # real signature unknown
       # 取差集,更新原集合
        """ Update a set with the symmetric difference of itself and another. """
        pass

 16. union():取並集,不更新原集合

 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

 17. update():取並集,更新原集合

def update(self, *args, **kwargs): # real signature unknown
      # 取並集,更新原集合
        """ Update a set with the union of itself and others. """
        pass

相關文章
相關標籤/搜索