删除,删除和弹出列表之间的区别

流过昼夜 提交于 2020-08-18 14:48:54

问题:

>>> a=[1,2,3]
>>> a.remove(2)
>>> a
[1, 3]
>>> a=[1,2,3]
>>> del a[1]
>>> a
[1, 3]
>>> a= [1,2,3]
>>> a.pop(1)
2
>>> a
[1, 3]
>>> 

Is there any difference between the above three methods to remove an element from a list? 以上三种从列表中删除元素的方法之间有什么区别吗?


解决方案:

参考一: https://stackoom.com/question/mL0O/删除-删除和弹出列表之间的区别
参考二: https://oldbug.net/q/mL0O/Difference-between-del-remove-and-pop-on-lists
标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!