“Python/gloss python remove tuple items”的版本间差异

来自菜鸟教程
跳转至:导航、​搜索
(Pywikibot 4.4.0.dev0)
 
(机器人:添加分类Python基础教程
 
第55行: 第55行:
 
</div>
 
</div>
 
<br />
 
<br />
 +
 +
[[分类:Python基础教程]]

2020年10月29日 (四) 08:48的最新版本

<languages />

Python删除元组项目

删除元组项目

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


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

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

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

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