(100 days, 2 hours, third day) del statement in the list

del statement:

         Use the del statement to delete an element from a list by index instead of value. This is different from using pop() to return a value. You can use the del statement to delete a cut from the list or empty the entire list.

a=[1,2,3,4,5,6]
del(a[0])
print(a)
a=[1,2,3,4,5,6]
del(a[2:4])
print(a)
a=[1,2,3,4,5,6] 
del(a) #也可以用来删除实体变量

  

Guess you like

Origin blog.csdn.net/zhangxue1232/article/details/109333829