tuple

內建元組類型。元組運算式範例:
x = (1, 2, 3)
您可透過索引 (從 0 起) 建立索引來存取元素:
e = x[1]   # e == 2
清單支援 + 運算子,可串連兩個元組。範例:
x = (1, 2) + (3, 4)   # x == (1, 2, 3, 4)
x = ("a", "b")
x += ("c",)            # x == ("a", "b", "c")
與清單類似,元組支援配量作業:
('a', 'b', 'c', 'd')[1:3]   # ('b', 'c')
('a', 'b', 'c', 'd')[::2]  # ('a', 'c')
('a', 'b', 'c', 'd')[3:0:-1]  # ('d', 'c', 'b')
元組無法變更,因此不支援 x[1] = "a"