notion image
数据容器——列表(list)嵌套的列表列表查询插入元素追加元素删除指定下标元素删除某个指定元素,匹配的第一项清空列表的方法统计某个元素出现的次数列表使用总结tuple 元组 (一旦定义不可修改)元组定义元组的相关操作(因为不可修改,所以操作少)字符串下标索引字符串的替换字符串的分割split——得到一个列表list字符串的规整操作 strip —— 去除字符串前后的一些东西字符串的count和len都可以用序列的切片操作切片set集合 ——不支持元素重复,元素无序添加新元素移除元素取出2个集合的差2个集合合并集合常用操作字典数据获取新增元素更新元素删除元素清空元素获取全部的Key常用操作总结数据容器总结下标索引分类特点对比应用场景

数据容器——列表(list)

notion image
元素类型无限制,下标从0开始
 
 

嵌套的列表

写入和取出方法
notion image
 
 

列表查询

notion image
notion image
 
使用方法
notion image
notion image
存放在class里面
 

插入元素

notion image
在指定的下标后一位插入

追加元素

notion image
在最后一位加入对应的元素

删除指定下标元素

notion image
两种语法

删除某个指定元素,匹配的第一项

notion image

清空列表的方法

notion image

统计某个元素出现的次数

notion image

列表使用总结

notion image
 

tuple 元组 (一旦定义不可修改)

元组定义

notion image
notion image

元组的相关操作(因为不可修改,所以操作少)

notion image
注意:元组里面的列表可以修改
notion image
 

字符串

字符串也支持下标 从0开始

下标索引

notion image

字符串的替换

notion image
notion image
注意要拿新的字
符串去接收,原来的还是不变
 
 

字符串的分割split——得到一个列表list

notion image
notion image
notion image
 

字符串的规整操作 strip —— 去除字符串前后的一些东西


 
notion image
notion image
notion image

字符串的count和len都可以用

 
 

序列的切片操作

切片

notion image
notion image
notion image
设置步长为2
notion image
 
 

set集合 ——不支持元素重复,元素无序

notion image
 

添加新元素

notion image
重复的不会添加进去,自动避免重复

移除元素

notion image
不要把移除后的东西重新赋值给一个东西

取出2个集合的差

notion image

2个集合合并

notion image

集合常用操作

notion image

字典

字典的定义
notion image
键值不能重复

数据获取

notion image
可以嵌套使用

新增元素

notion image

更新元素

notion image

删除元素

notion image

清空元素

notion image

获取全部的Key

notion image

常用操作总结

notion image

数据容器总结

下标索引分类

notion image

特点对比

notion image

应用场景

notion image