从 python 数组创建元素明智的字典

Create element wise dictionary from python arrays

来自这些数组:

t = ["A","B","C"]
a = [1,2,3]
b = [4,5,6]
c = [7,8,9]

如何获得这样的列表

[
  { 'A':1, 'B':4, 'C':7},
  { 'A':2, 'B':5, 'C':8},
  { 'A':3, 'B':6, 'C':9},
]

以便在 JSON 中转储更有用?

你可以这样做:

t_data = [a, b, c]
[{u:v for u, v in zip(t, xs)} for xs in zip(*t_data)]