python列表

定义列表:
1、通过【】 list1=[1,3,45,5,0]
2、通过list s="12345" c=list(s)

相关列表函数:
(1)通过索引添加内容(覆盖了原有内容)
image

(2)append 添加(默认添加到最后一位)
这一点和字典不同,优先级高一点
image

(3)insert  插入
image

(4)extend  合并两个列表
image

(5)remove 删除表中的值
image

(6)del 删除
image

(7)pop 默认删除最后一个函数
image

(8)reverse  反转
image

(9)sort 排序,默认升序

image

(10)sorted  排序(升序,降序)

image

(11)index 在列表中找到元素对应的索引
image

(12)根据切片来取值
image

posted @ 2026-05-12 14:35  刘sir金牌讲师  阅读(7)  评论(0)    收藏  举报