【发布时间】:2012-08-10 16:17:59
【问题描述】:
这可能是一个愚蠢的问题,但鉴于以下 dict:
combination_dict = {"one": [1, 2, 3], "two": [2, 3, 4], "three": [3, 4, 5]}
我将如何实现这个列表:
result_list = [{"one": [1, 2, 3], "two": [2, 3, 4]}, {"one": [1, 2, 3], "three": [3, 4, 5]}, {"two": [2, 3, 4], "three": [3, 4, 5]}]
换句话说,我想要一个字典中两个键/值对的所有组合,而不考虑顺序。
【问题讨论】:
-
为什么你的
result_list中没有"two"/"three"? -
感谢您指出这一点!
标签: python list dictionary combinations