Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
对于下面的元组列表:
[('a',1),('b', 2)]
我想将其转换为:
[{'a' : 1}, {'b', 2}]
这是一个字典列表
lst = [{k: v} for k, v in lst]
你的元组列表在哪里lst。
lst
[{t[0] : t[1]} for t in [('a',1),('b', 2)]]