python 元组(跟列表类似)
-
-
元组 表示多个元素组成的序列
-
元组 在
Python开发中,有特定的应用场景
-
-
用于存储 一串 信息,数据 之间使用
,分隔 -
元组用
()定义 -
元组的 索引 从
0开始 -
索引 就是数据在 元组 中的位置编号
info_tuple = ("zhangsan", 18, 1.75) print(info_tuple[0])
info_tuple = (50, )
info = ("zhangsan", 18) print("%s 的年龄是 %d" % info)
list(元组)
tuple(列表)
# 元组转换成列表 info_tuple = ("zhangsan", 18, 1.75) temp = list(info_tuple) print(temp) # 列表转换成元组 name_list = ["zhangsan","lisi"] temp2 = tuple(name_list) print(temp2)

浙公网安备 33010602011771号