>>> d
{'abcd': [2, 3, 4], 'bcd': [2, 3, 4]}
>>>
同鍵的後值覆蓋前值;
2. 字典合並操作要視妳的合並算法而定,例如:
>>> d0 = {'abcd':[1,2,3],'bcd':[1,2,3]}
>>> d1 = {'abcd':[2,3,4],'bcd':[2,3,4]}
>>> # 列表疊加:
>>> for k,v in d1.items():
... d0[k] = d0.get(k,[])+v
...
>>> d0
{'abcd': [1, 2, 3, 2, 3, 4], 'bcd': [1, 2, 3, 2, 3, 4]}
>>> # 合並為無重復項的條目
>>> for k,v in d1.items():
... d0[k] = list(set(d0.get(k,[])+v))
>>> d0 = {'abcd':[1,2,3],'bcd':[1,2,3]}
>>> for k,v in d1.items():
... d0[k] = list(set(d0.get(k,[])+v))
...
>>> d0
{'abcd': [1, 2, 3, 4], 'bcd': [1, 2, 3, 4]}