* { margin: 0; padding: 0; } .about { width: 100%; height: 100%; overflow: hidden; } .about_bgc { width: 100% } .about_tit { position: absolute; top: 280px; left: 0; right: 0; font-size: 28px; font-weight: 550; bottom: 0; width: 800px; margin: auto; text-align: center; } .ribbon { display: flex; justify-content: center; position: absolute; right: 300px; top: 50px; margin: auto; } .ribbon:after, .ribbon:before { margin-top: 0.5em; content: ""; display: flex; ; border: 1.5em solid #fff; } .ribbon:after { border-right-color: transparent; } .ribbon:before { border-left-color: transparent; } .ribbon a:link, .ribbon a:visited { color: #000; text-decoration: none; height: 3.5em; overflow: hidden; } .ribbon span { background: #fff; display: inline-block; line-height: 3em; padding: 0 1.5em; margin-top: 0.5em; position: relative; -webkit-transition: background-color 0.2s, margin-top 0.2s; /* Saf3.2+, Chrome */ -moz-transition: background-color 0.2s, margin-top 0.2s; /* FF4+ */ -ms-transition: background-color 0.2s, margin-top 0.2s; /* IE10 */ -o-transition: background-color 0.2s, margin-top 0.2s; /* Opera 10.5+ */ transition: background-color 0.2s, margin-top 0.2s; } .ribbon a:hover span { background: #FFD204; margin-top: 0; } .ribbon span:before { content: ""; position: absolute; top: 3em; left: 0; border-right: 0.5em solid #9B8651; border-bottom: 0.5em solid #fff; } .ribbon span:after { content: ""; position: absolute; top: 3em; right: 0; border-left: 0.5em solid #9B8651; border-bottom: 0.5em solid #fff; } .me { display: flex; justify-content: center; margin-top: 60px; overflow: hidden; } .me_tit { width: 600px; line-height: 36px; font-size: 18px; margin-left: 100px; margin-top: 50px; } .me_img { width: 800px; height: 600px; } .animate { padding-left: 20px; width: 500px; font-size: 16px; color: #000; animation: 10s wordsLoop linear infinite normal; } @keyframes wordsLoop { 0% { transform: translateY(100px); -webkit-transform: translateY(100px); } 100% { transform: translateY(-100%); -webkit-transform: translateY(-100%); } } .videos { display: flex; margin-top: 60px; padding-bottom: 80px; } .videos span { width: 400px; margin-right: 100px; margin-left: 300px; color: #FFD204 }

Python 笔记 2(序列)

序列

常用序列有:字符串,列表,元组,字典,集合
image
image
此图提前展示

列表

列表的创建

使用[ ]
列表的创建与元素的提取
法一:
image
法二:
list()创建
image

image

[========]

range()创建一个整数列表

标准格式:range(start,end,step)
--------- :range(开始值,结束值,取值步长)
range:不写默认值为 0
step:------1
image

image

列表元素的增加与删除

1.append()方法

image
添加元素后id不变

在列表尾部增加元素

2.+运算符操作

image
次运算 会改变原列表的地址 ,生成新的对象

3.extend方法

此方法属于原地操作,不断创新列表
列表id不会发生变化

image

4.insert()插入元素

  • 使用方法 a.insert(x,y)
    x:表示列表的位置(从0开始算)
    y:需要插入的新元素

image

5.乘法扩展

image
(与字符串操作相似)

列表元素的删除

1.del

删除指定位置的元素
image
本质是将后一个元素拷贝在前一个位置(原理类似)

2.pop()方法

删除并返回指定位置的元素,如诺为指定位置,则默认删除最后一个元素

image

3.remove()方法

删除首次出现的指定元素,若不存在,则抛出异常

image

列表元素的访问与计数

1.index()

获取指定元素在列表中首次出现的索引
语法:index(value,start,end)
value:列表中元素
start,end:范围

2.切片操作

slice[start🔚step]
实例:
image

若取负数
image

列表排序

a.sort()
该操作默认升序排列
image

a.sort(reverse=True)
降序排列
image

import random
random.shuffle(a)
打乱顺序
image

max 与 min 函数
取最值
max()
min()
image

sum()函数
数值型列表进行求和
非数值型会进行报错
image

多维列表

二维列表

创建列表

image

列表元素的提取(整行/单个元素)

image

元组(tuple)

元组函数的创建

1.使用小括号(小括号可以省略)

image

如果是元组中只有单独一个元素,元素后需要加“,”否则不会被系统认为

2.通过tuple()创建元组

image

元组元素的访问与计数

元组中元素无法进行修改
与列表有异曲同工之妙
zip操作:将多个列表元素组合成元组

image

posted @ 2023-02-01 20:06  #鲁班一号#  阅读(68)  评论(0)    收藏  举报