zoukankan      html  css  js  c++  java
  • 集合

    set

    创建空集合  a=set()

    转化一个数据为集合:set(obj),  注意数字不能直接转化成集合,其他都可以,只要是可迭代类型

    set(一个字典),则集合内元素为字典的键值:

    关键是集合内置了去重,交集,并集,差集,对称差集函数,这是别的数据类型没有的

    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
     
    实例:
      
  • 相关阅读:
    怎样才能充分利用SQL索引
    MS SQL存储过程编写经验和优化措施
    ASP調用存講過程總結
    調用外部的DLL(DllImportAttribute)
    MS SQL中的行轉列
    SQL Server乐观锁定和悲观锁定实例
    如何使用 JScript 從 HTML 網頁自動化 Excel
    了解SQL Server锁争用:NOLOCK 和 ROWLOCK 的秘密
    C#語法學習結構(Struct)
    四项技术 助你提高SQL Server的性能
  • 原文地址:https://www.cnblogs.com/yuanji2018/p/10098994.html
Copyright © 2011-2022 走看看