列表列表到dict

时间:2016-05-04 21:36:01

标签: python python-2.7

我列出了类似这样的列表

[['a',20],['b',30],['c',40],['d',50]]

我要把它转换成像这样的字典

{'a':20,'b':30,'c':40,'d':50}

怎么做?

1 个答案:

答案 0 :(得分:3)

>>> a = [['a',20],['b',30],['c',40],['d',50]]
>>> b = dict(a)
>>> print b
{'a': 20, 'c': 40, 'b': 30, 'd': 50}