
用list或[]真正创建列表,赋值只是重命名。


此处第二个位置指第0,1,2个位置


.append()添加元素到最后,只能操作一个元素,多个需要+=列表操作。
.sort()排序
.reverse()反转元素
.index()查找元素索引
.insert(i, x)在i位置插入x元素,插入不是修改,先位置后元素。
.count()统计元素数量
.remove()删除第一次出现的元素
.pop()弹出元素,并删除。
用list或[]真正创建列表,赋值只是重命名。
此处第二个位置指第0,1,2个位置
.append()添加元素到最后,只能操作一个元素,多个需要+=列表操作。
.sort()排序
.reverse()反转元素
.index()查找元素索引
.insert(i, x)在i位置插入x元素,插入不是修改,先位置后元素。
.count()统计元素数量
.remove()删除第一次出现的元素
.pop()弹出元素,并删除。
本文标题:列表相关的库和函数
本文链接:https://www.haomeiwen.com/subject/fkhjqqtx.html
网友评论