from collections import OrderedDict # SortedDict of Django gets removed: https://code.djangoproject.com/wiki/SortedDict
my_orderded_dict=OrderedDict([('one', 1), ('three', 3)])
new_orderded_dict=my_orderded_dict.__class__()
for key, value in my_orderded_dict.items():
new_orderded_dict[key]=value
if key=='one':
new_orderded_dict['two']=2
my_orderded_dict.clear()
my_orderded_dict.update(new_orderded_dict)
print my_orderded_dict
相关问题 更多 >
编程相关推荐