📜  python 从列表中删除项目 - Python 代码示例

📅  最后修改于: 2022-03-11 14:46:29.646000             🧑  作者: Mango

代码示例1
# Remove from List
[1,2,3].pop()    # 3 --> mutates original list, default index in the pop method is -1 (the last item)
[1,2,3].pop(1)   # 2 --> mutates original list
[1,2,3].remove(2)# None --> [1,3] Removes first occurrence of item or raises ValueError.
[1,2,3].clear()  # None --> mutates original list and removes all items: []
del [1,2,3][0] #