python del方法从列表中删除某个项目索引,这个和列表的pop方法不一样,pop方法则返回一个值。

>>> a = [-1, 1, 66.25, 333, 333, 1234.5]
>>> del a[0]
>>> a
[1, 66.25, 333, 333, 1234.5]
>>> del a[2:4]
>>> a
[1, 66.25, 1234.5]
>>> del a[:]
>>> a
[]

也可用于删除整个变量: del a

相关文章:

  • 2022-12-23
  • 2021-06-03
  • 2022-02-13
  • 2021-06-22
  • 2021-07-28
  • 2021-10-12
猜你喜欢
  • 2021-07-23
  • 2022-12-23
  • 2021-11-24
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案