這可能是Python中的一個經典問題,但我還沒有找到答案。如何將字典列表轉換爲Python中的列表字典?
我有一個詞典列表,這些詞典有類似的鍵。 它看起來像這樣:
[{0: myech.MatchingResponse at 0x10d6f7fd0,
3: myech.MatchingResponse at 0x10d9886d0,
6: myech.MatchingResponse at 0x10d6f7d90,
9: myech.MatchingResponse at 0x10d988ad0},
{0: myech.MatchingResponse at 0x10d6f7b10,
3: myech.MatchingResponse at 0x10d6f7f90>}]
我想獲得一個新的字典[0,3,6,9]作爲鍵,和「myech.MatchingResponse」作爲值的列表。
當然,我可以使用一個簡單的循環來做到這一點,但我想知道是否有更有效的解決方案。
對於反向看(從字典-的-列表列出-的-http://stardict.sourceforge.net/Dictionaries.php下載):https://stackoverflow.com/q/1780174/1959808 – 2017-09-20 01:45:06
相關:https://stackoverflow.com/q/30522982/1959808 – 2017-09-20 01:54:46