008 tuple 元组
-
特点: 可获取,不可修改,有序
tuple_var = () print(tuple_var, type(tuple_var)) 结果: () <class 'tuple'>
2.定义元组:
message = (1,2,3,4) print(message, type(message)) print(message[-1], message[0]) 结果: (1, 2, 3, 4) <class 'tuple'> 4 1
3.判定元组的类型
都好是区分元组的标识符
mes01 = (12,) mes02 = 12, print(mes01, type(mes01),mes02,type(mes02)) 结果: (12,) <class 'tuple'> (12,) <class 'tuple'>