美文网首页
python列表相关操作函数

python列表相关操作函数

作者: 余生还长你别慌 | 来源:发表于2019-10-06 18:01 被阅读0次
  1. append,insert 插入 list1.insert(0,'red')--在0位置插入red ------- 列表支持加和乘
  2. remove,pop删除 list1.remove('red')--删除第一个red
  3. sort(reserve=True)---sort方法会改变原列表,但sorted函数不会
  4. len
  5. min/max
  6. extend列表扩展,直接修改原列表,而加号是生成新列表
  7. index---list1.index(‘red’)--list1中red元素的索引
  8. count 计算某个元素出现的次数 如何一行代码去掉重复元素?
    reverse-倒着打印列表
  9. enumerate-遍历列表,得到index和value

相关文章

网友评论

      本文标题:python列表相关操作函数

      本文链接:https://www.haomeiwen.com/subject/qonupctx.html