我知道,Python列表可以附加或扩展。有没有一种简单的方法,以两个Python字典具有独特的按键组合,例如:
basket_one = {'fruit': 'watermelon', 'veggie': 'pumpkin'}
basket_two = {'dairy': 'cheese', 'meat': 'turkey'}
我再想食品的一个大篮子:
basket = {
'fruit': 'watermelon',
'veggie': 'pumpkin',
'dairy': 'cheese',
'meat': 'turkey'
}
我怎么能执行上述在Python?
Dup of http://stackoverflow.com/questions/577234/python-extend-for-a-dictionary – gnud 2009-10-11 20:27:55