返回顶部

收藏

Remove an item from a list given its index instead of its value: the del statement

更多
# Unlike the pop()) method which returns a value, the del keyword is a statement and 
# can also be used to remove slices from a list (which we did earlier by assignment 
# of an empty list to the slice).

a = [-1, 1, 66.25, 333, 333, 1234.5]
del a[0]
print a

del a[2:4]
print a

# del can also be used to delete entire variables:
a = [-1, 1, 66.25, 333, 333, 1234.5]

del a

标签:Python,Buildin,Function

收藏

0人收藏

支持

0

反对

0

发表评论