# 2.3循环遍历# ●取值就是从元组中获取存储在指定位置的数据# ●遍历就是从头到尾依次从元组中获取数据# .for循环内部使用的变量 in 元组# for iten in info:# 循环内部针对元组元素进行操作# print(iten)# ●在Python 中,可以使用for循环遍历所有非数字型类型的变量:列表、元组、字# 典以及字符串# ●提示:在实际开发中,除非能够确认元组中的数据类型,否则针对元组的循环遍历# 需求并不是很多info_tuple = ("小明",18,170)#格式化字符串后面的 '()' 本质上是元祖print("%s 年龄是 是%d 身高 %.2f" % info_tuple)info_str = "%s 年龄是 %d 身高是 %.2f " % info_tupleprint(info_str)# 列表元祖互相转换 (用的python交互式)# >>> num_list = [1,2,3,4]# >>> type (num_list)# <class 'list'># >>> tuple(num_list)# (1, 2, 3, 4)# >>> num_tuple=tuple(num_list)# >>> type(num_tuple)# <class 'tuple'># >>> num2_list=list(num_tuple)# >>> type(num2_list)# <class 'list'>#info_tuple = ("小明",18,170)#for xxx in info_tuple: #print(xxx)