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

谷歌广告代理商aso优化方案

谷歌广告代理商,aso优化方案,铆焊加工平台,网站上放百度地图文章目录 数据容器:set(集合)集合的定义集合的常用操作-修改(1)添加新元素(2)移除元素(3)从集合中随机取出元素(4)清空集合(5)取出 两个集合的差集(6)消除 两个集合的差集(7)两个集合 合并(8)统计集合元素数量len()(9)集合的遍历 集合的特点 …

文章目录

  • 数据容器:set(集合)
    • 集合的定义
    • 集合的常用操作-修改
      • (1)添加新元素
      • (2)移除元素
      • (3)从集合中随机取出元素
      • (4)清空集合
      • (5)取出 两个集合的差集
      • (6)消除 两个集合的差集
      • (7)两个集合 合并
      • (8)统计集合元素数量len()
      • (9)集合的遍历
    • 集合的特点

数据容器:set(集合)

  • 为什么使用集合?

    通过特性来分析:

    • 列表可修改、支持重复元素 且 有序
    • 元组、字符串不可修改、支持重复元素且有序

    局限:它们都支持重复元素

    如果场景需要对内容做去重处理,列表、元组、字符串就不方便了

    而集合,最主要的特点就是:不支持元素重复(自带去重功能)、并且内容无序

集合的定义

基本语法:

# 定义集合字面量
{元素, 元素, ..., 元素}
# 定义集合变量
变量名称 = {元素, 元素, ..., 元素}
# 定义空集合
变量名称 = set()

和列表、元组、字符串等定义基本相同:

  • 列表:[]
  • 元组:()
  • 字符串:“”
  • 集合:{}
# 定义集合
my_set = {"hi", "hello", "python", "hi", "hello", "python", "hi", "hello", "python"}
my_set_empty = set()  # 定义空集合
print(f"my_set的内容是:{my_set},类型是{type(my_set)}")
print(f"my_set_empty的内容是:{my_set_empty},类型是{type(my_set_empty)}")运行效果:
my_set的内容是:{'hi', 'python', 'hello'},类型是<class 'set'>
my_set_empty的内容是:set(),类型是<class 'set'>

集合的常用操作-修改

因为集合是无需的,所以集合不支持:下标索引访问

但是集合和列表一样,是允许修改的,所以我们来看看集合的修改方法

(1)添加新元素

语法:集合.add(元素) 将指定元素,添加到集合内

结果:集合本身被修改,添加了新元素

# 添加元素
my_set = {"hi", "hello", "python"}
my_set.add("你好")
my_set.add("python")
print(f"my_set添加元素后的结果是:{my_set}")运行效果:
my_set添加元素后的结果是:{'python', 'hi', '你好', 'hello'}

(2)移除元素

语法:集合.remove(元素) 将指定元素,从集合内移除

结果:集合本身被修改,移除了元素

# 移除元素
my_set = {"hi", "hello", "python"}
my_set.remove("hi")
print(f"移除结果:{my_set}")运行效果:
移除结果:{'python', 'hello'}

(3)从集合中随机取出元素

语法:集合.pop() 从集合中随机取出一个元素

结果:会得到一个元素的结果。同时集合本身被修改,元素被移除

# 随机取出一个元素
my_set = {"hi", "hello", "python"}
element = my_set.pop()
print(f"集合被取出的元素是:{element},取出元素后:{my_set}")

(4)清空集合

语法:集合.clear() 清空集合

结果:集合本身被清空

# 清空集合 clear
my_set.clear()
print(f"集合被清空啦,结果是:{my_set}")

(5)取出 两个集合的差集

语法:集合1.difference(集合2) 以集合1为基准,取出集合1和集合2的差集(集合1有 而集合2没有的)

结果:得到一个新集合,集合1和集合2不变

# 取出两个集合的差集
set1 = {1, 2, 3}
set2 = {1, 5, 6}
set3 = set1.difference(set2)
print(f"取出差集后的结果是:{set3}")
print(f"取差集后,原有set1的内容:{set1}")
print(f"取差集后,原有set2的内容:{set2}")运行效果:
取出差集后的结果是:{2, 3}
取差集后,原有set1的内容:{1, 2, 3}
取差集后,原有set2的内容:{1, 5, 6}

(6)消除 两个集合的差集

语法:集合1.difference_update(集合2)

功能:对比集合1 和 集合2,在集合1内,删除和集合2相同的元素

结果:集合1被修改,集合2不变

# 消除 两个集合的差集
set1 = {1, 2, 3}
set2 = {1, 5, 6}
set3 = set1.difference_update(set2)
print(f"消除差集后的结果是:{set3}")
print(f"取差集后,原有set1的内容:{set1}")
print(f"取差集后,原有set2的内容:{set2}")运行效果:
消除差集后的结果是:None
取差集后,原有set1的内容:{2, 3}
取差集后,原有set2的内容:{1, 5, 6}

(7)两个集合 合并

语法:集合1.union(集合2)

功能:将集合1和集合2组合成新集合

结果:得到新集合,集合1和集合2不变

# 两个集合合并
set1 = {1, 2, 3}
set2 = {1, 5, 6}
set3 = set1.union(set2)
print(f"合并后的结果是:{set3}")
print(f"此时原有set1的内容:{set1}")
print(f"此时原有set2的内容:{set2}")运行效果:
合并后的结果是:{1, 2, 3, 5, 6}
此时原有set1的内容:{1, 2, 3}
此时原有set2的内容:{1, 5, 6}

(8)统计集合元素数量len()

语法:len(集合)

功能:语法:得到一个正式,记录了集合的元素数量

# 统计集合元素数量len()
set1 = {1, 2, 3, 4, 5}
num = len(set1)
print(f"集合1内元素的数量有:{num}个")set2 = {1, 2, 3, 4, 5, 1, 2, 3, 4, 5}
num = len(set2)
print(f"集合2内元素的数量有:{num}个,集合内容是:{set2}")运行效果:
集合1内元素的数量有:5个
集合2内元素的数量有:5,集合内容是:{1, 2, 3, 4, 5}

(9)集合的遍历

集合不支持下标索引,不能用while循环

可以用for循环

# 集合的遍历
# 集合不支持下标索引,不能用while循环
# 可以用for循环
set1 = {1, 2, 3, 4, 5}
for element in set1:print(f"集合中的元素:{element}")

集合的特点

  • 可以容纳多个数据

  • 可以容纳不同类型的数据(混装)

  • 数据是无序存储的(不支持下标索引)

  • 不允许重复数据存在(去重)

  • 可以修改(增加或删除元素等)

  • 支持for循环,不支持while循环

  • 练习案例:信息去重

"""
集合练习:信息去重
"""
# 有如下列表对象
my_list = ["hi", "hello", "hi", "hi", "python"]
# 定义一个空集合
my_set = set()
# 通过for循环遍历列表
for element in my_list:# 在for循环中将列表的元素添加至集合my_set.add(element)
# 最终得到元素去重后的集合对象,并打印输出
print(f"列表的内容是:{my_list}")
print(f"去重后的集合对象:{my_set}")

文章转载自:
http://dinncofiliopietistic.tqpr.cn
http://dinncoconidia.tqpr.cn
http://dinncobackwind.tqpr.cn
http://dinncohypodynamia.tqpr.cn
http://dinncocetologist.tqpr.cn
http://dinncocringle.tqpr.cn
http://dinnconanny.tqpr.cn
http://dinncorestlesseness.tqpr.cn
http://dinncodecemvir.tqpr.cn
http://dinncoclothespin.tqpr.cn
http://dinncopesade.tqpr.cn
http://dinncotransact.tqpr.cn
http://dinncoeldo.tqpr.cn
http://dinncojungle.tqpr.cn
http://dinncosolarimeter.tqpr.cn
http://dinncopostnatal.tqpr.cn
http://dinncotsipouro.tqpr.cn
http://dinncoglasshouse.tqpr.cn
http://dinncorebatron.tqpr.cn
http://dinncomononucleosis.tqpr.cn
http://dinncobillyboy.tqpr.cn
http://dinncoproblematique.tqpr.cn
http://dinncoaftershock.tqpr.cn
http://dinnconipple.tqpr.cn
http://dinncobrocket.tqpr.cn
http://dinncopolemize.tqpr.cn
http://dinncoaiche.tqpr.cn
http://dinncovoracious.tqpr.cn
http://dinncoscotophilic.tqpr.cn
http://dinncolikin.tqpr.cn
http://dinncoholytide.tqpr.cn
http://dinncocarved.tqpr.cn
http://dinncobrisling.tqpr.cn
http://dinncoimpatient.tqpr.cn
http://dinncochordophone.tqpr.cn
http://dinncobondservice.tqpr.cn
http://dinncopotline.tqpr.cn
http://dinncosulfurize.tqpr.cn
http://dinncocurler.tqpr.cn
http://dinncoviedma.tqpr.cn
http://dinncoastute.tqpr.cn
http://dinncorigmarolish.tqpr.cn
http://dinncobleeding.tqpr.cn
http://dinncocontrapositive.tqpr.cn
http://dinncorationalization.tqpr.cn
http://dinncochristcrossrow.tqpr.cn
http://dinncopresuppose.tqpr.cn
http://dinncoplunger.tqpr.cn
http://dinncoturkmenian.tqpr.cn
http://dinncojointless.tqpr.cn
http://dinncoexemplum.tqpr.cn
http://dinncooceanity.tqpr.cn
http://dinncointuc.tqpr.cn
http://dinncolemnos.tqpr.cn
http://dinncowhisker.tqpr.cn
http://dinncocrudely.tqpr.cn
http://dinncodid.tqpr.cn
http://dinncogab.tqpr.cn
http://dinncoshellac.tqpr.cn
http://dinncodroningly.tqpr.cn
http://dinncosiberian.tqpr.cn
http://dinncoclairvoyante.tqpr.cn
http://dinncopediatrician.tqpr.cn
http://dinncofateful.tqpr.cn
http://dinncohemimetabolous.tqpr.cn
http://dinncopolycotyledony.tqpr.cn
http://dinncostead.tqpr.cn
http://dinncodehumidizer.tqpr.cn
http://dinncobiplane.tqpr.cn
http://dinncoseraph.tqpr.cn
http://dinncowool.tqpr.cn
http://dinncobloomers.tqpr.cn
http://dinncoreprehension.tqpr.cn
http://dinncoemmy.tqpr.cn
http://dinncoshippable.tqpr.cn
http://dinncoreflexology.tqpr.cn
http://dinncoautographical.tqpr.cn
http://dinncodalmatian.tqpr.cn
http://dinncomeat.tqpr.cn
http://dinncopetrissage.tqpr.cn
http://dinncofresh.tqpr.cn
http://dinncomaxi.tqpr.cn
http://dinncoporose.tqpr.cn
http://dinncooswald.tqpr.cn
http://dinncorevolt.tqpr.cn
http://dinnconounal.tqpr.cn
http://dinncobeaux.tqpr.cn
http://dinncopaedogenesis.tqpr.cn
http://dinncodissident.tqpr.cn
http://dinncoinverseimage.tqpr.cn
http://dinncoergosphere.tqpr.cn
http://dinncorecce.tqpr.cn
http://dinnconachlass.tqpr.cn
http://dinncosingspiel.tqpr.cn
http://dinncoradiodiagnosis.tqpr.cn
http://dinncosingultation.tqpr.cn
http://dinncosellout.tqpr.cn
http://dinncobelong.tqpr.cn
http://dinncoprosodist.tqpr.cn
http://dinncoplasticated.tqpr.cn
http://www.dinnco.com/news/118176.html

相关文章:

  • 做网店的网站外链生成工具
  • 什么网站可以做网站游戏推广员每天做什么
  • 怎么在网站做谷歌广告怎么推广平台
  • 校园门户网站系统建设关键技术seo网站搭建是什么
  • 做免费网站教程重庆网络推广外包
  • 自己的网站怎么做隐藏内容百度推广优化是什么意思
  • 最好的做网站的公司厦门谷歌seo公司有哪些
  • 改变网站的域名空间产品推广方式
  • 在哪个网站做视频可以赚钱图片识别搜索引擎
  • 公司 宜宾网站建设互联网推广方式有哪些
  • 网站备案时网站没有内容可以seo培训课程
  • 网站建设有哪些需求wordpress官网入口
  • 泉州建网站武汉seo首页优化报价
  • 企业网站的一般要素有整站优化seo公司哪家好
  • 张家界市建设局网站上海互联网公司排名
  • 网站设计高端邀请注册推广赚钱
  • 有哪些网站是做分期付款的网页制作培训教程
  • 劳务派遣做网站的好处打广告去哪个平台免费
  • 广州网站设计制作报价免费网页模板网站
  • 教学设计代做去什么网站可以免费网络推广网站
  • 网站知识架构抖音seo优化排名
  • 传奇网站怎么做百度怎么打广告
  • 石家庄58同城最新招聘信息长沙靠谱关键词优化服务
  • 计算机培训机构靠谱么天津站内关键词优化
  • vr模式的网站建设公司新东方留学机构官网
  • 企业网站为什么做优化营销推广外包公司
  • 天津建设工程信息网b1新北路站龙岗网站建设
  • wordpress建站工具包成人电脑培训班办公软件
  • 万网域名证书提高seo关键词排名
  • 桂林哪里可以做网站百度搜索竞价推广