4
嗨,請我如何可以追加在嵌套列表詞典列表元組形成的元組爲後續的新列表:建築元組
nde = [{'length': 0.35, 'modes': 'cw', 'type': '99', 'lanes': 9},
{'length': 0.48, 'modes': 'cw', 'type': '99', 'lanes': 9},
{'length': 0.88, 'modes': 'cw', 'type': '99', 'lanes': 9}]
dge = [[(1001, 7005),(3275, 8925)], [(1598,6009),(1001,14007)]]
我如何追加他們有結果從而格式化:
rslt = [(1001, 7005, {'length': 0.35, 'modes': 'cw', 'type': '99', 'lanes': 9}... ]
我嘗試這樣做:
[(k1[0], k1[1], k2) for k1, k2 in zip(dge, nde)]
但它不給所期望的結果。由於
「nde」中有三個字典,但'dge'中有兩個列表/四個元組。這似乎很奇怪。 – DSM