【发布时间】:2022-06-14 23:03:13
【问题描述】:
我有一个嵌套元组,如下所示:
(67, (150, 58, 3, 3, 1, 2))
以及如下的键列表
['James', 'weight', 'height', 'n_kids', 'n_cars', 'n_house', 'n_phones']
我正在尝试将元组转换为如下字典:
{'James':67, {'weight':150, 'height':58, 'n_kids':3, 'n_cars':3,'n_house':1, 'n_phones':2}}
最好的方法是什么?
谢谢!
【问题讨论】:
-
您忘记发布解决此问题的尝试。
标签: python dictionary