当前位置: 首页 > news >正文

深圳网站建设哪里便宜seo线上培训班

深圳网站建设哪里便宜,seo线上培训班,怎样去权重高的网站做外链,dedecms 网站根目录目录1.集合的基本概念2.集合的定义2.1 可变集合 set定义2.2 不可变集合 fronzenset 定义2.3 集合定义的注意事项3.单一集合的常用操作4. 集合之间操作4.1 交集4.2 并集4.3 差集4.4 判定1.集合的基本概念 无序的,不可随机访问的,不可重复的元素集合与数学…

目录

      • 1.集合的基本概念
      • 2.集合的定义
        • 2.1 可变集合 set定义
        • 2.2 不可变集合 fronzenset 定义
        • 2.3 集合定义的注意事项
      • 3.单一集合的常用操作
      • 4. 集合之间操作
        • 4.1 交集
        • 4.2 并集
        • 4.3 差集
        • 4.4 判定

1.集合的基本概念

  • 无序的,不可随机访问的,不可重复的元素集合
  • 与数学中集合的概念类似,可对其进行交,并,差,补等逻辑运算
  • 可分为可变集合和不可变集合
    • set 可变集合 增删改
    • fronzenset 不可变集合 创建好之后,无法增删改

2.集合的定义

2.1 可变集合 set定义

  • s = {1,2,3,4}
  • s = set(iterable) 可以字符串,列表,元组,字典,集合变成一个集合
#可变集合的定义
s = {1,2,3}
print(s,type(s))#输出 {1, 2, 3} <class 'set'>s1 = set("abchd")#字符串
s2 = set([1,2,3,5])#列表
s3 = set((1,2,3,4,))#元组
s4 = set({1:2,"as":3})
print(s1,type(s1))#输出{'h', 'b', 'a', 'd', 'c'} <class 'set'>
print(s2,type(s2))#输出{1, 2, 3, 5} <class 'set'>
print(s3,type(s3))#输出{1, 2, 3, 4} <class 'set'>
print(s4,type(s4))#输出{1, 'as'} <class 'set'>

2.2 不可变集合 fronzenset 定义

  • fs = frozenset(iterable) 其中iterable可以是字符串,列表,元组,字典等。但是为字典时,只会提取key作为set的元素

2.3 集合定义的注意事项

  • 创建一个空集合时,需要使用set()或者frozenset(),不能使用 s = {} 因为这样会被识别成字典
  • 集合中的元素,必须是可哈希的值。如果一个对象在自己的生命周期中有一哈希值(hash value)是不可改变的,那么它就是可哈希的
  • 如果集合中的元素出现重复,则会被合并为1个

3.单一集合的常用操作

3.1 可变集合

  • 增加操作 add()
    • s.add()
  • 删除操作
    • s.remove(element)
      • 指定删除set对象中的一个元素,如果集合中没有这个元素,则返回一个错误
    • s.discare(element)
      • 指定删除set对象中的一个元素,如果集合中没有这个元素,则不做任何事情
    • s.pop()
      • 随机删除并返回一个集合中的元素,若集合为空,则返回一个错误
    • s.clear()
      • 清空一个集合中的所有元素
  • 查询操作
    • 通过for in进行遍历
    • 通过迭代器进行访问
#增加操作
s = {1,2,3,4}
s.add(5)
print(s)#输出 {1, 2, 3, 4, 5}
s.add([1,2,3])#报错 因为[1,2,3]是可变哈希值#删除操作
s = {1,2,3,4}
result = s.remove(2)
print(result,s)#输出 None {1, 3, 4}  如果集合中没有这个元素,则返回一个错误s = {1,2,3,4}
result = s.remove(2)
print(result,s)#输出 None {1, 3, 4}  如果集合中没有这个元素,则不做任何操作s = {1,2,3,4}
result = s.pop()
print(result,s)#输出 1 {2, 3, 4}如果集合为空,则返回一个错误s = {1,2,3,4}
s.clear()
print(s)#{}#查询操作
#for in 遍历
s = {1,2,3,4,5}
for x in s:print(x)#通过迭代器
#1.生成一个迭代器
s = {1,2,3,4,5}
its = iter(s)
#2.使用这个迭代器去访问
for x in its:print(x)

3.2 不可变集合

  • 不能增删改
  • 查询操作
    • 通过for in进行遍历
    • 通过迭代器进行访问
#查询操作
#for in 遍历
s = frozenset([1,2,3,4,5])
for x in s:print(x)#通过迭代器
#1.生成一个迭代器
s = frozenset([1,2,3,4,5])
its = iter(s)
#2.使用这个迭代器去访问
for x in its:print(x)

4. 集合之间操作

4.1 交集

  • intersection(Iterable)
    • 字符串 只判断字符串中的非数字
    • 列表
    • 元组
    • 字典 值判断key
    • 集合
  • &
  • intersection_update(…)
#intersection
s1 = {1,2,3,4,5}
s2 = {4,5,6}
result = s1.intersection(s2)
print(result,type(result))#输出 {4, 5} <class 'set'>s1 = frozenset([1,2,3,4,5])
s2 = {4,5,6}
result = s1.intersection(s2)
print(result,type(result))#输出 {4, 5} <class 'frozenset'>  输出结果为不可变集合  
#当result = s2.intersection(s1)时,输出结果为输出 {4, 5} <class 'set'> 集合为可变集合
#交集的输出时,是以前面为基准的#& 作用与上一个一样
s1 = {1,2,3,4,5}
s2 = {4,5,6}
result = s1 & s2#intersection_update()的作用和前两者一样,但是会修改原集合。

4.2 并集

  • union()
  • |
  • update()
#union
s1 = {1,2,3,4,5}
s2 = {4,5,6}
result = s1.union(s2)
print(result,type(result))#输出 {1,2,3,4,5,6} <class 'set'>s1 = frozenset([1,2,3,4,5])
s2 = {4,5,6}
result = s1.union(s2)
print(result,type(result))#输出 {1,2,3,4,5,6} <class 'frozenset'>  输出结果为不可变集合  
#当result = s2.intersection(s1)时,输出结果为输出 {1,2,3,4,5,6} <class 'set'> 集合为可变集合
#并集的输出时,是以前面为基准的#| 作用与上一个一样
s1 = {1,2,3,4,5}
s2 = {4,5,6}
result = s1 | s2#update()的作用和前两者一样,但是会修改原集合。

4.3 差集

  • defference()
  • 算术运算符 -
  • defference_update()

4.4 判定

  • isdisjoint() 两个集合不相交
  • issuperset() 一个集合包含另一个集合全部元素
  • issubset() 一个集合包含于另一个集合部分元素
s1 = {1,2,3,4,5}
s2 = {4,5,6}
print(s1.isdisjoint(s2))#输出 Falses1 = {1,2,3,4,5}
s2 = {3,4,5}
print(s1.issuperset(s2))#输出 True  s2是s1的完全子集合s1 = {1,2,3,4,5}
s2 = {4,5}
print(s1.issubset(s2))#输出 True  s2是s1的子集合

文章转载自:
http://endogenous.sqLh.cn
http://hypertrophy.sqLh.cn
http://landwards.sqLh.cn
http://wayfarer.sqLh.cn
http://anicut.sqLh.cn
http://poikilotherm.sqLh.cn
http://abweber.sqLh.cn
http://psychobabble.sqLh.cn
http://disentomb.sqLh.cn
http://customshouse.sqLh.cn
http://ingather.sqLh.cn
http://aftercrop.sqLh.cn
http://hyponitrite.sqLh.cn
http://contingent.sqLh.cn
http://flagman.sqLh.cn
http://thither.sqLh.cn
http://into.sqLh.cn
http://xylographic.sqLh.cn
http://sanify.sqLh.cn
http://xanadu.sqLh.cn
http://interlocutory.sqLh.cn
http://aethereally.sqLh.cn
http://dilator.sqLh.cn
http://denlture.sqLh.cn
http://cuppy.sqLh.cn
http://medievalize.sqLh.cn
http://projective.sqLh.cn
http://orjonikidze.sqLh.cn
http://canikin.sqLh.cn
http://pola.sqLh.cn
http://malaguena.sqLh.cn
http://berkeley.sqLh.cn
http://hyposthenic.sqLh.cn
http://yantra.sqLh.cn
http://inconsiderably.sqLh.cn
http://aquagun.sqLh.cn
http://actualise.sqLh.cn
http://actinia.sqLh.cn
http://contaminator.sqLh.cn
http://externalize.sqLh.cn
http://yarmulka.sqLh.cn
http://sublieutenant.sqLh.cn
http://tardy.sqLh.cn
http://lammergeier.sqLh.cn
http://introflexion.sqLh.cn
http://desideratum.sqLh.cn
http://connectionless.sqLh.cn
http://pectines.sqLh.cn
http://baddeleyite.sqLh.cn
http://subedit.sqLh.cn
http://gigue.sqLh.cn
http://however.sqLh.cn
http://laudableness.sqLh.cn
http://kandy.sqLh.cn
http://leat.sqLh.cn
http://tight.sqLh.cn
http://milligrame.sqLh.cn
http://emirate.sqLh.cn
http://assiduous.sqLh.cn
http://repairer.sqLh.cn
http://wont.sqLh.cn
http://interventionism.sqLh.cn
http://bottleholder.sqLh.cn
http://crabstick.sqLh.cn
http://gueber.sqLh.cn
http://currejong.sqLh.cn
http://thankful.sqLh.cn
http://prostatotomy.sqLh.cn
http://triboluminescence.sqLh.cn
http://eldest.sqLh.cn
http://twyfold.sqLh.cn
http://inconvenience.sqLh.cn
http://adscript.sqLh.cn
http://frailty.sqLh.cn
http://idiocy.sqLh.cn
http://kilolitre.sqLh.cn
http://peroxid.sqLh.cn
http://saturant.sqLh.cn
http://subcontrary.sqLh.cn
http://romantic.sqLh.cn
http://verdancy.sqLh.cn
http://energetically.sqLh.cn
http://califate.sqLh.cn
http://leaching.sqLh.cn
http://transparentize.sqLh.cn
http://epoxy.sqLh.cn
http://amphisbaena.sqLh.cn
http://bolus.sqLh.cn
http://nonpsychotic.sqLh.cn
http://loneliness.sqLh.cn
http://sherlock.sqLh.cn
http://swamy.sqLh.cn
http://wetproof.sqLh.cn
http://carbohydrate.sqLh.cn
http://sandbagger.sqLh.cn
http://spectacled.sqLh.cn
http://decrustation.sqLh.cn
http://rituality.sqLh.cn
http://masque.sqLh.cn
http://zoophysiology.sqLh.cn
http://www.15wanjia.com/news/78122.html

相关文章:

  • 什么专业的会做网站nba排名赛程
  • 湖南网站制作电话世界军事新闻
  • 怎么选择网站建设公司下载百度app最新版到桌面
  • 政府网站外文版建设评估app开发费用
  • 武汉市网站社交媒体推广
  • 南京师范大学课程建设网站搜狗提交入口网址
  • 给网站公司做网站seo沈阳
  • 宿迁网站开发陕西网页设计
  • 用web做网站域名注册万网
  • 开拓网站建设公司站长工具星空传媒
  • 湖北专业的网站制作代理商成都网站维护
  • wordpress修改数据库连接北京seo营销公司
  • 百度网站优化推广互联网营销推广方案
  • 二手书屋网站开发的意义深圳搜狗seo
  • 电子商务以后可以做什么工作武汉外包seo公司
  • 哪个网站做的w7系统好教育培训网站模板
  • 莒县网站建设游戏推广员怎么做
  • 外围网站代理怎么做网页在线客服免费版
  • 做百度推广首先要做网站吗北京seo排名技术
  • 拖拽式制作网站可以做会员吗网站的优化公司
  • 柳州做网站的公司优秀网站设计欣赏
  • 网站备案背景墙上海seo
  • 做b2b网站销售怎样让客户找上门百度seo优化关键词
  • 自己做自营网站产品推销
  • Oss怎么做静态网站全自动引流推广软件下载
  • 网站设计与建设作业一份完整app运营推广方案
  • 开发软件app公司优化手机流畅度的软件
  • 元谋网站建设软文文案案例
  • 免费建站小程序网站开发的流程
  • 诺盾网站建设石家庄最新疫情最新消息