Clarify how python del works for lists and slices

前端 未结 2 1115
温柔的废话
温柔的废话 2021-01-21 14:33

Reading the docs:

del: Deletion of a target list recursively deletes each target, from left to right.

Can you clarify why this cod

2条回答
  •  遇见更好的自我
    2021-01-21 15:04

    From the doc:

    list.clear() Remove all items from the list. Equivalent to del a[:].

    del a[:] equals a.clear()

    You can try to print id(a) and id(c),they're different objects.

提交回复
热议问题