1. python-内建函数-多迭代对象聚合
-
zip()函数:对多个可迭代对象创建一个聚合,返回一个元组的迭代器
-
示例:
x = [1,2,3] y = [4,5,6] zipped = zip(x,y) print(list(zipped))
2. 案例
#!/usr/bin/env python3
# _*_ coding: utf-8 _*_
# Author:shichao
# File: .py
x = [1,2,3]
y = [4,5,6]
zipped = zip(x,y)
print(list(zipped))
# 同时遍历两个列表,把两个列表变成字典
标签:聚合,迭代,zip,python,zipped,内建函数
From: https://www.cnblogs.com/scajy/p/17029614.html