刪除,刪除和彈出列表之間的區別 - Difference between del, remove and pop on lists

問題:

>>> 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? 以上三種從列表中刪除元素的方法之間有什麼區別嗎? spa


解決方案:

參考一: https://stackoom.com/question/mL0O/刪除-刪除和彈出列表之間的區別
參考二: https://oldbug.net/q/mL0O/Difference-between-del-remove-and-pop-on-lists
相關文章
相關標籤/搜索