我知道,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