零基础和我一起学Python系统 第六天 列表和元组
第六天 列表和元组
知识点
- 查找
- 增加
- 删除
- 修改
查找
一、查找
下标
直接通过下标查数据
注意 下标从0开始 
index
查找子串出现 的位置 注意 查找不到,报错 
count
统计子串出现的次数 
len
统计列表中的个数 
判断 是否存在
in
判断指定数据是否在列表中,在的话,返回True

not in 判断指定数据是否在列表中,不在的话,返回True

二,增加
增加指定数据到列表
append
列尾

注意 列表为可变数据类型
extend
列尾

注意 extend 会把列表拆开
insert
指定位置增加
 注意 insert 第一个参数为下标,要填写
三,删除
del
 注意
也可以删除整个列表

pop

注意 直接删除列表序列
remove

注意
如果remove 的值不整在,则会报错
clear
 clear clear 为清空列表,清空后,变成空列表
四,修改
修改指定下标的数据
直接用 列表[下标] = 值
 reverse
 sort
 注意 降序的话,只需要把reverse = True

总结
第六天学习Python ,熟悉了解python的列表和元组语法。
|