正常情况下:
# coding=utf-8

fruit = ['apple', 'pear', 'banana' ]
#指定索引删除
fruit.pop(0)
#符合元素删除,具体数值
fruit.remove('pear')
print(fruit) 运行结果:
['banana']

反例:

pop用指定元素:
# coding=utf-8

fruit = ['apple', 'pear', 'banana' ]
fruit.pop('apple') 运行结果:
Traceback (most recent call last):
File "...XXX.py", line 5, in <module>
fruit.pop('apple')
TypeError: 'str' object cannot be interpreted as an integer

remove用索引:

# coding=utf-8

fruit = ['apple', 'pear', 'banana' ]
fruit.remove(0)
print(fruit) 运行结果:
Traceback (most recent call last):
File "...XXX.py", line 4, in <module>
fruit.remove(0)
ValueError: list.remove(x): x not in list

最新文章

  1. 升级python2.7至python3
  2. B树详解
  3. PL/0编译器(java version) &ndash; Scanner.java
  4. git: No refs in common and none specified; doing no
  5. Linux安全运维日志排查几个 tips
  6. java多线程模拟停车系统
  7. poj 3252 Round Numbers 【推导&#183;排列组合】
  8. [转贴] C++内存管理检测工具 Valgrind
  9. iOS- 解决iOS10 App启动时放大铺满App Icon的问题
  10. 《英文写作指南 The elements of style》【PDF】下载
  11. IDEA jsp模板
  12. linux socket编程之TCP与UDP
  13. [Swift]LeetCode159.具有最多两个不同字符的最长子串 $ Longest Substring with At Most Two Distinct Characters
  14. 使用ML.NET实现白葡萄酒品质预测
  15. 算法——001BitMap(位图)算法
  16. hive命令的三种执行方式
  17. 利用OCR识别扫描的jpg、tif文件的文字
  18. python的__getitem__
  19. Hbase 维护
  20. ASP.NET 构建高性能网站 第1篇

热门文章

  1. 专业视频图片水印清除工具丨HitPaw Watermark Remover 2.1.3
  2. 解决Google翻译不能用的问题
  3. 基2和基4FFT
  4. MaaS模型即服务
  5. window操作
  6. uniapp 配置钉钉小程序package.json文件
  7. 滚动 Scroller OverScroller
  8. sed 命令添加字符串
  9. C#和.NET Framework 简介
  10. python torch 解决OSError: [WinError 126] 找不到指定的模块。 Error loading &quot;D:\Anaconda3\lib\site-packages\torch\lib\asmjit.dll&quot; or one of its dependencies.(安装完torch模块后出现找不到指定模块的问题)