python元组声明要带逗号
t2, t3, t4 = (2), (2,),() print(type(t2),type(t3), type(t4)) #<class 'int'> <class 'tuple'> <class 'tuple'>
元组可以加、乘操作
t1 = (1,3,5,7) t2 = (2,4,6,8) print((t1*3+t2)[2:]) #(5, 7, 1, 3, 5, 7, 1, 3, 5, 7, 2, 4, 6, 8)
元组可以用一个元素加上一个逗号来声明;
t1,t2,t3 = (1),2,3, print(type(t1),type(t2),type(t3)) # <class 'int'> <class 'int'> <class 'int'> t4 = 1, print(type(t4)) # <class 'tuple'>