【问题标题】:Creating a new dictionary from lists of tuples and characters从元组和字符列表创建新字典
【发布时间】:2021-12-26 21:47:58
【问题描述】:

我有两个列表示例:

list1=[(0,1), (0,2), (1,3),...]

list 2: ["louis", "Montgomery", ...]

如何创建这样的字典:

{(0,1) : "louis", (0,2) : 'Montgomery", ...}

【问题讨论】:

  • 您使用哪种编程环境?请详细说明以启用答案。

标签: dictionary tuples


【解决方案1】:

试试这个:

dict(zip(list1,list2))

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-02-10
    • 2011-08-29
    • 2014-12-18
    • 2021-08-14
    相关资源
    最近更新 更多