串联运算符如何在Python中的元组上工作?

串联运算符使用初始元组按添加的顺序在Python中创建一个新元组。这不是就位操作。 

示例

tuple1 = [1, 2, 3]
tuple2 = ['a', 'b']
tuple3 = tuple1 + tuple2
print(tuple3)

输出结果

这将给出输出-

[1, 2, 3, 'a', 'b']