官术网_书友最值得收藏!

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.

主站蜘蛛池模板: 冷水江市| 盈江县| 上蔡县| 马尔康县| 江源县| 建水县| 通榆县| 双鸭山市| 图木舒克市| 特克斯县| 乌兰察布市| 自贡市| 武鸣县| 大新县| 桂阳县| 三原县| 大同县| 汤原县| 凤阳县| 衡东县| 新田县| 大埔县| 渑池县| 岱山县| 英吉沙县| 华阴市| 常州市| 敦煌市| 石屏县| 象州县| 冀州市| 澄江县| 枣庄市| 青龙| 龙山县| 柞水县| 象山县| 仲巴县| 肇东市| 云霄县| 温泉县|