内置元组类型。元组表达式示例:
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"
。