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