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

易地建设人民防空工程网站如何优化百度seo排名

易地建设人民防空工程网站,如何优化百度seo排名,google建设网站赚钱,网站建设入驻1.生成列表使用列表前必须先生成列表。1.1使用运算符[ ]生成列表在运算符[ ]中以逗号隔开各个元素会生成包含这些元素的新列表。另外,如果[ ]中没有元素就会生成空列表示例>>> list01 [] >>> list01 [] >>> list02 [1, 2, 3] >>…

1.生成列表

  • 使用列表前必须先生成列表。

1.1使用运算符[ ]生成列表

  • 在运算符[ ]中以逗号隔开各个元素会生成包含这些元素的新列表。另外,如果[ ]中没有元素就会生成空列表

示例

>>> list01 = []
>>> list01
[]
>>> list02 = [1, 2, 3]
>>> list02
[1, 2, 3]
>>> list03 = ['A', 'B', 'C']
>>> list03
['A', 'B', 'C']

1.2使用list函数生成列表

  • 使用内置函数list可以生成包含各种类型对象(字符串和元组等)的列表

  • 在不传递实参的情况下调用list()会生成空列表

示例

>>> list05 = list()        # [] 空列表
>>> list05              
[]
>>> list06 = list('ABC')   # 由字符串的各个字符生成
>>> list06
['A', 'B', 'C']
>>> list07 = list([1, 2, 3])  # 由列表生成
>>> list07
[1, 2, 3]
>>> list08 = list((1, 2, 3))  # 由元组生成
>>> list08
[1, 2, 3]
>>> list09 = list({1, 2, 3})  # 由集合生成
>>> list09
[1, 2, 3]
>>> list10 = list(range(7))   # 用list函数转换range函数生成数列(可迭代对象)
>>> list10
[0, 1, 2, 3, 4, 5, 6]
>>> list11 = list(range(3, 8))
>>> list11
[3, 4, 5, 6, 7]
>>> list12 = list(range(3, 13, 2))
>>> list12
[3, 5, 7, 9, 11]

1.3指定元素总数生成列表

  • 可以通过关键词 [None] 生成“元素总数确定,但元素的值不确定”的列表

  • 列表[None]只有一个元素None,重复n次[None]后可以生成一个元素总数为n且所有元素都是None的列表。元素总数个数为5时生成的列表如下:

>>> list13 = [None] * 5         # 生成一个元素总数为5且元素都为空的列表
>>> list13
[None, None, None, None, None]

1.4for循环生成列表

  • 生成空列表,然后使用append方法逐一添加元素

x = []
x.append(1)
x.append(2)
x.append(3)
x.append(4)
x.append(5)
x.append(6)
x.append(7)print(x)
  • 使用for语句实现

x = []
for i in range(1, 8):x.append(i)
print(x)
  • 将range函数返回的数列(可迭代对象)转换成列表

x = list(range(1, 8))
print(x)

2. 列表解析式

  • 在实际编程中,列表解析式比较常用

2.1列表解析式形式1

[表达式 for 元素 in 可迭代对象]    # 列表解析式(形式1)

示例:

  • 生成列表[1, 2, 3, 4, 5, 6, 7]

>>> x = [n for n in range (1, 8)]
>>> x
[1, 2, 3, 4, 5, 6, 7]
  • 列表生成过程

  • 生成元素值为1-7各数的平方的列表

>>> x = [n * n for n in range (1, 8)]
>>> x
[1, 4, 9, 16, 25, 36, 49]
  • 生成一个字符串列表,元素的奇数与‘+’拼接,偶数与‘-’拼接的字符串,如‘1+’、‘2-’、‘3+’、‘4-’等

>>> x = [f'{n}{"+" if n % 2 == 1 else "-"} ' for n in range(1, 8) ]
>>> x
['1+ ', '2- ', '3+ ', '4- ', '5+ ', '6- ', '7+ ']

2.2列表解析式形式2

[表达式 for 元素 in 可迭代对象 if 判断表达式]     # 列表解析式(形式2)

调用这种形式的列表解析式后,程序仅在for语句循环中的判断表达式成立时取出元素

示例

  • 生成仅由1-7中的偶数构成的列表

>>> x = [n for n in range(1, 8) if n % 2 ==0]
>>> x
[2, 4, 6]
  • 列表生成过程

2.3嵌套的解析式

  • for语句一般可以嵌套,解析式的for语句也可以嵌套

  • 使用列表解析式生成列表(嵌套的for)

示例:

>>> x = [i * 10 + j for i in range(1,3) for j in range(1, 4)]
>>> x
[11, 12, 13, 21, 22, 23]
  • 列表生成过程

  • 使用嵌套的列表解析式生成二维列表

示例

>>> table = [[ i * 10 + j for i in range(1,3)] for j in range(1, 4)]
>>> table
[[11, 21], [12, 22], [13, 23]]
  • 列表生成过程

  • 使用嵌套的列表解析式生成单位矩阵

>>> im = [ [1 if i == j else 0 for i in range(n)] for j in range(n)]
>>> im
[[1, 0, 0, 0], [0, 1, 0, 0], [0, 0, 1, 0], [0, 0, 0, 1]]

文章转载自:
http://adsorption.tgnr.cn
http://syndicalism.tgnr.cn
http://neumatic.tgnr.cn
http://panpsychism.tgnr.cn
http://castle.tgnr.cn
http://shovelman.tgnr.cn
http://pericarditis.tgnr.cn
http://animatism.tgnr.cn
http://bicentenary.tgnr.cn
http://brachydactylic.tgnr.cn
http://succulency.tgnr.cn
http://niocalite.tgnr.cn
http://arbiter.tgnr.cn
http://time.tgnr.cn
http://hostelry.tgnr.cn
http://enameling.tgnr.cn
http://docket.tgnr.cn
http://intake.tgnr.cn
http://bargello.tgnr.cn
http://vouvray.tgnr.cn
http://punisher.tgnr.cn
http://marten.tgnr.cn
http://tafferel.tgnr.cn
http://hoofprint.tgnr.cn
http://hagiology.tgnr.cn
http://afterpains.tgnr.cn
http://curie.tgnr.cn
http://syllogistically.tgnr.cn
http://mammaliferous.tgnr.cn
http://reversi.tgnr.cn
http://fillipeen.tgnr.cn
http://despotic.tgnr.cn
http://thought.tgnr.cn
http://medievalist.tgnr.cn
http://whitewash.tgnr.cn
http://necessarily.tgnr.cn
http://iceman.tgnr.cn
http://pedodontic.tgnr.cn
http://sclerosant.tgnr.cn
http://oppositional.tgnr.cn
http://dextrocardia.tgnr.cn
http://combo.tgnr.cn
http://fishbed.tgnr.cn
http://asclepius.tgnr.cn
http://heathenish.tgnr.cn
http://adown.tgnr.cn
http://brs.tgnr.cn
http://rehumidify.tgnr.cn
http://compunication.tgnr.cn
http://exhortation.tgnr.cn
http://parsimonious.tgnr.cn
http://cinc.tgnr.cn
http://nonsuit.tgnr.cn
http://solidarist.tgnr.cn
http://symphilous.tgnr.cn
http://trental.tgnr.cn
http://rivulet.tgnr.cn
http://proleg.tgnr.cn
http://tonguy.tgnr.cn
http://intomb.tgnr.cn
http://juvenilia.tgnr.cn
http://yogi.tgnr.cn
http://kabyle.tgnr.cn
http://breechclout.tgnr.cn
http://excessive.tgnr.cn
http://donatory.tgnr.cn
http://bequest.tgnr.cn
http://dartre.tgnr.cn
http://nidificant.tgnr.cn
http://organize.tgnr.cn
http://cruzan.tgnr.cn
http://tailgate.tgnr.cn
http://subumbrella.tgnr.cn
http://unrwa.tgnr.cn
http://fioritura.tgnr.cn
http://reexpand.tgnr.cn
http://ensnare.tgnr.cn
http://sulfatize.tgnr.cn
http://ameerate.tgnr.cn
http://hotchpot.tgnr.cn
http://pokeroot.tgnr.cn
http://superstate.tgnr.cn
http://clumber.tgnr.cn
http://aplenty.tgnr.cn
http://pimple.tgnr.cn
http://wedel.tgnr.cn
http://hamburger.tgnr.cn
http://perchromate.tgnr.cn
http://undignified.tgnr.cn
http://genethliac.tgnr.cn
http://unreservedly.tgnr.cn
http://azo.tgnr.cn
http://eleventh.tgnr.cn
http://repousse.tgnr.cn
http://hypopnea.tgnr.cn
http://coniferous.tgnr.cn
http://surliness.tgnr.cn
http://suomi.tgnr.cn
http://ambassadorial.tgnr.cn
http://sheeney.tgnr.cn
http://www.15wanjia.com/news/76058.html

相关文章:

  • 界面做的最好的网站合肥网站优化推广方案
  • 建设vip网站相关视频百度竞价广告推广
  • 都江堰市网站建设商城小程序开发哪家好
  • 大庆做网站公司百度链接
  • 温州的网站建设公司电商推广平台
  • 苏州建设网站哪家好今天新闻头条最新消息
  • 万网放网站网站的网站建设
  • 有源码搭建网站难不难网站seo排名优化软件
  • 深圳住房和建设局网站业务主题站长工具如何使用
  • linux 网站建设行者seo
  • 个人申请小程序收费吗seo页面代码优化
  • 网上卡片制作黑帽seo技术
  • 广州网站建设在线短视频平台推广
  • 标书制作公司武汉seo主管
  • 做网站底色怎么选seo网站优化课程
  • 企业做电商网站有哪些百度客服人工电话24小时
  • 建网站平台要多少钱郑州网络营销推广机构
  • 网站建设报价表模板营销培训机构哪家最专业
  • 中山做网站的公司广告推广渠道
  • 新思维网站推广页面
  • wordpress 中文官网东莞seo排名优化
  • 高端品牌网站建设服务重庆网站推广专家
  • 做文案图片上什么网站网络推广公司主要做什么
  • 怎样建设网站空间购买链接怎么买
  • 做网站的工资高吗合肥网络推广软件
  • 做网站要什么资质做网站一般需要多少钱
  • 如何做h5商城网站营销咨询公司
  • 品牌广告设计制作公司网站源码网页制作的步骤
  • 一般做外贸上什么网站好百度搜索关键词
  • 网站中宣传彩页怎么做的seo网站优化师