Given a dictionary that looks like this:
{
'Color': ['Red', 'Yellow'],
'Size': ['Small', 'Medium', 'Large']
}
How can I create a list of dictionaries that combines the various values of the first dictionary's keys? What I want is:
[
{'Color': 'Red', 'Size': 'Small'},
{'Color': 'Red', 'Size': 'Medium'},
{'Color': 'Red', 'Size': 'Large'},
{'Color': 'Yellow', 'Size': 'Small'},
{'Color': 'Yellow', 'Size': 'Medium'},
{'Color': 'Yellow', 'Size': 'Large'}
]
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…