示例程序如下:
>>> a = [-1, 3, ‘aa‘, 85] # 定义一个list
>>> a
[-1, 3, ‘aa‘, 85]
>>> del a[0] # 删除第0个元素
>>> a
[3, ‘aa‘, 85]
>>> del a[2:4] # 删除从第2个元素开始,到第4个为止的元素。包括头不包括尾
>>> a
[3, ‘aa‘]
>>> del a # 删除整个list
>>> a
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
NameError: name ‘a‘ is not defined
>>>