Python/gloss python remove tuple items

来自菜鸟教程
机器人讨论 | 贡献2020年10月29日 (四) 08:48的版本 (机器人:添加分类Python基础教程
(差异) ←上一版本 | 最后版本 (差异) | 下一版本→ (差异)
跳转至:导航、​搜索

<languages />

Python删除元组项目

删除元组项目

注意: 您不能删除元组中的项目。


元组是 不可改变的 ,因此您无法从中删除项目,但可以完全删除元组:

The del 关键字可以完全删除元组:

thistuple = ("apple", "banana", "cherry")

  del
thistuple
print(thistuple)
  #this will raise an error because the tuple no longer exists