更新时间:2023-01-17 18:58:11
If the order matters, then you can use collections.OrderedDict
to collect all the items, like this
from collections import OrderedDict
print OrderedDict((d["key"], d) for d in my_list).values()
如果顺序无关紧要,您可以使用像这样的普通词典
And if the order doesn't matter, you can use a normal dictionary, like this
print {d["key"]:d for d in my_list}.values()