这是我目前如何在Python中将元组列表转换为字典:
l = [('a',1),('b',2)] h = {} [h.update({k:v}) for k,v in l] > [None, None] h > {'a': 1, 'b': 2}
有没有更好的办法?似乎应该有一个单行来做这件事.
python dictionary tuples list
dictionary ×1
list ×1
python ×1
tuples ×1