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

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.

主站蜘蛛池模板: 乌海市| 泸西县| 修武县| 育儿| 宽甸| 游戏| 渭南市| 贵阳市| 凤翔县| 房山区| 福清市| 沅江市| 平顺县| 东兴市| 西充县| 梁河县| 全椒县| 土默特右旗| 吉林省| 镶黄旗| 九龙城区| 襄城县| 唐河县| 伊春市| 友谊县| 安阳市| 丁青县| 保德县| 贵州省| 景泰县| 巴彦县| 富平县| 平顺县| 玛曲县| 宽城| 南京市| 普陀区| 漠河县| 天台县| 湘潭县| 清远市|