- 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范例大全
- The Modern C++ Challenge
- Linux核心技術從小白到大牛
- 編譯系統透視:圖解編譯原理
- Cocos2d-x學習筆記:完全掌握Lua API與游戲項目開發 (未來書庫)
- Python編程:從入門到實踐(第3版)
- 汽車人機交互界面整合設計
- Mastering Gephi Network Visualization
- Sails.js Essentials
- Visual Basic語言程序設計基礎(第3版)
- 寫給青少年的人工智能(Python版·微課視頻版)
- 實戰Python網絡爬蟲
- Building Clouds with Windows Azure Pack
- Web程序設計與架構