- Mastering Python Scripting for System Administrators
- Ganesh Sanjiv Naik
- 72字
- 2021-07-02 14:00:24
Deleting tuple elements
We cannot remove individual tuple elements. So, to remove an entire tuple explicitly, use the del statement. Refer to the following example:
#!/usr/bin/python3
cities = ('Mumbai', 'Bangalore', 'Chennai', 'Pune')
print ("Before deleting: ", cities)
del cities
print ("After deleting: ", cities)
Output:
Before deleting: ('Mumbai', 'Bangalore', 'Chennai', 'Pune')
Traceback (most recent call last):
File "01.py", line 5, in <module>
print ("After deleting: ", cities)
NameError: name 'cities' is not defined
推薦閱讀
- Java高并發核心編程(卷2):多線程、鎖、JMM、JUC、高并發設計模式
- Mastering OpenCV Android Application Programming
- Visual FoxPro 程序設計
- 一塊面包板玩轉Arduino編程
- 開源項目成功之道
- 細說Python編程:從入門到科學計算
- Scratch·愛編程的藝術家
- Qlik Sense? Cookbook
- Python趣味編程與精彩實例
- Node.js從入門到精通
- Mastering SciPy
- Selenium WebDriver Practical Guide
- DevOps 精要:業務視角
- Learn Linux Quickly
- 第五空間戰略:大國間的網絡博弈