Python如何把一个元组完全删除掉?

1 个回答|82 次阅读
Coco老师 - 科普专家
擅长:编程教育

del语句可以完全删除元组:

fruittuple = ("apple", "banana", "cherry")
del fruittuple
print(fruittuple

执行结果:表明元组不存在了

Traceback (most recent call last):
File "d:\users\xingc\desktop\7.py", line 3, in <module>
print(fruittuple)
NameError: name 'fruittuple' is not defined