zoukankan      html  css  js  c++  java
  • 集合

      1 # 变量类型
      2 
      3 # 不可变类型:字符串  数字  元组
      4 
      5 # 可变类型: 列表  字典  集合
      6 
      7 
      8 # 访问顺序:
      9 # 直接访问:数字
     10 # 顺序方访问: 字符串  列表  元组
     11 # 映射: 字典(无序)
     12 
     13 # 存放元素个数:
     14 # 容器类型 : 列表  元组  字典
     15 # 原子:数字  字符串
     16 
     17 # 集合:由不同元素组成的集合,集合中是一组无序排列的可hash值,可以作为字典的key
     18 # s= {1,2,3,4,5,6}
     19 #
     20 # 特性:集合的目的是将不同的值存放在
     21 
     22 
     23 #s = {1,2,3,3,3,33,3,3,3,3,3,3,3}
     24 # a = type(s)
     25 #print(s)
     26 
     27 # s = set('kissyou')
     28 # print(s)
     29 
     30 # s = {1,2,3,5,6,7}
     31 # s.add(9)
     32 # s.add('9')
     33 # print(s)
     34 
     35 
     36 # s = {1,2,3,5,6,7}
     37 # s.clear()
     38 # print(s)
     39 
     40 # s = {1,2,3,5,6,7}
     41 # s1 = s.copy()
     42 # print(s1)
     43 
     44 
     45 # s = {1,2,3,5,6,7,'ii','pp'}
     46 # #
     47 # # s.pop()  #####随机删除
     48 # s.remove('pp')     删除元素不存在会报错
     49 #s.discard           #删除元素不存在不会报错
     50 #  print(s)
     51 
     52 
     53 #求交集
     54 #intersection    &
     55 
     56 # s = {'a','b','c','d'}
     57 # i = {'b','c','k'}
     58 # print(s.intersection(i) )
     59 # print(s&i)
     60 
     61 
     62 
     63 #求并集
     64 # union   |
     65 # s = {'a','b','c','d'}
     66 # i = {'b','c','k'}
     67 # print(s.union(i)  )
     68 # print(s|i)
     69 
     70 
     71 
     72 #差集  -
     73 
     74 # s = {'a','b','c','d'}
     75 # i = {'b','c','k'}
     76 # print(s-i )
     77 # print(i-s)
     78 # print(s.difference(i) )
     79 # print(i.difference(s) )
     80 
     81 
     82 #交叉补集   symmetric_difference    ^
     83 
     84 # s = {'a','b','c','d'}
     85 # i = {'b','c','k'}
     86 # print(s.symmetric_difference(i)  )
     87 # print(i^s )
     88 
     89 #         difference_update
     90 # s = {'a','b','c','d'}
     91 # i = {'b','c','k'}
     92 # s = i.difference_update(s)
     93 # print(i)
     94 
     95 ####################
     96 # s = {'a','d'}
     97 # i = {'b','c','k'}
     98 # print(s.isdisjoint(i) )
     99 
    100 #  i 是 s 的子集
    101 # s = {1,2,3,4,5}
    102 # i = {2,3,4}
    103 # print(i.issubset(s) )
    104 
    105 # 父集
    106 # s = {1,2,3,4,5}
    107 # i = {2,3,4}
    108 # print(s.issuperset(i)  )
    109 
    110 #  add只能更新一个值   update可以更新很多值
    111 # s = {1,2,3,4,5}
    112 # i = {2,3,46}
    113 # s.update(i)
    114 # print(s)
    115 
    116 
    117 #  不可变集合
    118 # s=frozenset('oopop')
    119 # print(s)
    120 
    121 #集合变列表
    Never compromise.
  • 相关阅读:
    关于region Of interstROI
    二值图贴标签算法
    最大方差阈值分割OTSU
    已知空间N点坐标求圆心坐标,半径
    Blob Analysis Blob 分析
    前言
    Go基础学习
    Hive(数据仓库工具)
    Could not transfer artifact XXX,transfer failed for XXX 解决方案
    Docker
  • 原文地址:https://www.cnblogs.com/luoluokang/p/12433101.html
Copyright © 2011-2022 走看看