示例1:

for i, j in zip(range(0, 10), range(1, 11)):
    print(i, j)

输出结果:

0 1
1 2
2 3
3 4
4 5
5 6
6 7
7 8
8 9
9 10

示例2:

names = ['张三', '李四', '王五', '赵六']
ages = [22, 23, 25, 24]
citys = ['重庆', '北京', '天津', '上海']

for name, age, city in zip(names, ages, citys):
    print('%s--%d--%s' % (name, age, city))

输出结果:

张三--22--重庆
李四--23--北京
王五--25--天津
赵六--24--上海

相关文章:

  • 2021-05-30
  • 2022-12-23
  • 2021-04-28
  • 2022-12-23
  • 2022-12-23
  • 2021-05-16
  • 2021-12-07
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案