List(列表)
序列是Python中最基本的数据结构。序列中的每个元素都分配一个数字 - 它的位置,或索引,第一个索引是0,第二个索引是1,依此类推。
Python有6个序列的内置类型,但最常见的是列表和元组。
序列都可以进行的操作包括索引,切片,加,乘,检查成员。
此外,Python已经内置确定序列的长度以及确定最大和最小的元素的方法。
列表是最常用的Python数据类型,它可以作为一个方括号内的逗号分隔值出现。

与字符串的索引一样,列表索引从0开始。列表可以进行截取、组合等。
删除列表元素
可以使用 del 语句来删除列表的元素,如下实例:
以下是输出结果:

Python列表函数及方法

网友评论