Python 3.x 当两个OrderedPict中的键相同时,如何添加两个OrderedPict?

Python 3.x 当两个OrderedPict中的键相同时,如何添加两个OrderedPict?,python-3.x,ordereddictionary,Python 3.x,Ordereddictionary,我的第一份订单是 OrderedDict([('3LEmxb4G9q5XnP9H5653ncMAbAgbDCzz8U', {'value': 0.5, 'valueSat': 50000000, 'txid': '4c4e1609392f6744cdf9ff57614eb5f6905f39baba8f046c3b3bd5a1e6b573c8'}), ('1ErSPkXKfdVgjseia1psccr6ng4zbyLNSE', {'value': 0.01349045, 'valueSat': 1

我的第一份订单是

OrderedDict([('3LEmxb4G9q5XnP9H5653ncMAbAgbDCzz8U', {'value': 0.5, 'valueSat': 50000000, 'txid': '4c4e1609392f6744cdf9ff57614eb5f6905f39baba8f046c3b3bd5a1e6b573c8'}), ('1ErSPkXKfdVgjseia1psccr6ng4zbyLNSE', {'value': 0.01349045, 'valueSat': 1349045, 'txid': '4c4e1609392f6744cdf9ff57614eb5f6905f39baba8f046c3b3bd5a1e6b573c8'})])
我的第二个订单是

OrderedDict([('3LEmxb4G9q5XnP9H5653ncMAbAgbDCzz8U', {'account_id': None, 'last_block': '', 'n_conf': 0, 'total_confirmations': 3}), ('1ErSPkXKfdVgjseia1psccr6ng4zbyLNSE', {'account_id': None, 'last_block': '', 'n_conf': 0, 'total_confirmations': 6})])

在上述两个顺序中,键相同,但值不同。如何合并两个OrderedPicts中相同键的值并创建一个新键?

以下是代码:

from collections import OrderedDict
a= OrderedDict([('3LEmxb4G9q5XnP9H5653ncMAbAgbDCzz8U', {'value': 0.5, 'valueSat': 50000000, 'txid': '4c4e1609392f6744cdf9ff57614eb5f6905f39baba8f046c3b3bd5a1e6b573c8'}), ('1ErSPkXKfdVgjseia1psccr6ng4zbyLNSE', {'value': 0.01349045, 'valueSat': 1349045, 'txid': '4c4e1609392f6744cdf9ff57614eb5f6905f39baba8f046c3b3bd5a1e6b573c8'})])
b=OrderedDict([('3LEmxb4G9q5XnP9H5653ncMAbAgbDCzz8U', {'account_id': None, 'last_block': '', 'n_conf': 0, 'total_confirmations': 3}), ('1ErSPkXKfdVgjseia1psccr6ng4zbyLNSE', {'account_id': None, 'last_block': '', 'n_conf': 0, 'total_confirmations': 6})])
c=OrderedDict()

for key in a:
    temp=b[key]
    temp.update(a[key])
    c[key]=temp
print c

你的新词典是用c语言存储的。请记住
.update()
更新字典本身并返回
None

如何将此解决方案推广到添加N OrderedDict()?