Transform tuple to dict

后端 未结 1 425
醉话见心
醉话见心 2020-12-19 13:23

How can I transform tuple like this:


(
    (\'a\', 1),
    (\'b\', 2)
)

to dict:


{
    \'a\': 1,
    \'b\': 2
}


        
相关标签:
1条回答
  • 2020-12-19 13:55

    Dict constructor can do this for you.

    dict((
        ('a', 1),
        ('b', 2)
    ))
    
    0 讨论(0)
提交回复
热议问题