【问题标题】:Python: Convert nested Tuples into dictionaryPython:将嵌套元组转换为字典
【发布时间】: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


猜你喜欢
  • 1970-01-01
  • 2013-12-07
  • 2021-06-14
  • 2017-01-20
  • 1970-01-01
  • 2019-12-28
  • 1970-01-01
  • 2018-02-16
相关资源
最近更新 更多