实现以下目标的最 pythonic 方式是什么:
list_a = ["A", "B", "C"]
list_b = ["X", "Y", "Z"]
idx_start = 100
result = [ (100, "A", "X"), (101, "B", "Y"), (102, "C", "Z") ]
保证列表的大小相同。
最佳答案
from itertools import count
zip(count(idx_start), list_a, list_b)
关于python - 将两个列表的项目合并到也包含索引的元组列表中,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29035143/