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
     
    实例:
      
  • 相关阅读:
    PHP中单引号与双引号的区别分析
    utf8_unicode_ci与utf8_general_ci的区别
    [mysql-Ver5.6.23] windows版my.ini配置
    Gateway/Worker模型 数据库使用示例
    php 字符串 以 开头 以结尾 startWith endWith
    MySQL错误ERROR 2002 (HY000): Can't connect to local MySQL server
    vim变ide
    在Vue中使用样式
    Vue指令之`v-model`和`双向数据绑定
    Vue指令之事件修饰符
  • 原文地址:https://www.cnblogs.com/yuanji2018/p/10098994.html
Copyright © 2011-2022 走看看