- Learn Programming in Python with Cody Jackson
- Cody Jackson
- 134字
- 2021-06-10 19:06:11
Tuples
The final built-in data type is the tuple. Python tuples work exactly like Python lists except they are immutable; that is, they can't be changed in place. They are normally written inside parentheses to distinguish them from lists (which use square brackets), but as you'll see, parentheses aren't always necessary; however, a comma is always required, as expressions can use parentheses too. Since tuples are immutable, their length is fixed. To grow or shrink a tuple, a new tuple must be created.
Since parentheses can surround expressions, you have to show Python when a single item is actually a tuple by placing a comma after the item. A tuple without parentheses can be used when a tuple is unambiguous. However, it's easier to just use parentheses than to screenshot out when they're optional.
- Advanced Machine Learning with Python
- 自己動(dòng)手實(shí)現(xiàn)Lua:虛擬機(jī)、編譯器和標(biāo)準(zhǔn)庫(kù)
- Interactive Data Visualization with Python
- 無(wú)代碼編程:用云表搭建企業(yè)數(shù)字化管理平臺(tái)
- 認(rèn)識(shí)編程:以Python語(yǔ)言講透編程的本質(zhì)
- Python 3破冰人工智能:從入門到實(shí)戰(zhàn)
- C++從入門到精通(第5版)
- Developing SSRS Reports for Dynamics AX
- C編程技巧:117個(gè)問(wèn)題解決方案示例
- Python Programming for Arduino
- Appcelerator Titanium:Patterns and Best Practices
- Splunk Essentials
- 前端架構(gòu)設(shè)計(jì)
- 深入理解Zabbix監(jiān)控系統(tǒng)
- 軟件測(cè)試項(xiàng)目實(shí)戰(zhàn)之功能測(cè)試篇