python-遍历多个序列
遍历多个序列
""" @Filename: pro1/遍历多个序列 @Author: Titen @Time: 2022/6/6 10:16 @Describe: 遍历多个序列 """ seq_1 = [1,2,3,4,5] seq_2 = ("u","v","w","x","y") def Traverse_multiple_seq(): """ zip() 函数用于将可迭代的对象作为参数,将对象中对应的元素打包成一个个元组,然后返回由这些元组组成的列表。 """ for i, j in zip(seq_1, seq_2): print("当前 i 和 j重组后: %s 和 %s" % (i, j)) print("zip_seq结果: ", list(zip(seq_1, seq_2))) Traverse_multiple_seq() #--------------序列重组-------------- seq_3 = [6,7,8,9] seq_4 = ["Titen","城下作画"] list_1 = [] for i in *seq_3,*seq_4: list_1.append(i) print(list_1)
如下图:
本文来自博客园,作者:Titen,转载请注明原文链接:https://www.cnblogs.com/chengxiazuohua/p/16347408.html