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

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.

主站蜘蛛池模板: 庆阳市| 东乌珠穆沁旗| 长沙县| 玉林市| 儋州市| 田阳县| 庆元县| 双城市| 中宁县| 泌阳县| 同江市| 尉犁县| 五常市| 南木林县| 柳江县| 云和县| 鄂尔多斯市| 延安市| 长丰县| 梓潼县| 阳城县| 西华县| 耿马| 揭阳市| 怀安县| 旌德县| 建始县| 康马县| 陵水| 霍林郭勒市| 沂水县| 丰都县| 繁峙县| 东阳市| 商水县| 扶绥县| 遂溪县| 囊谦县| 馆陶县| 耿马| 边坝县|