Here is my OrderedDict
o=OrderedDict([('xmllist', 123), ('A', 124), ('B', 125), ('C', 126), ('D', 127)])
How can i interchange its keys and values as ,
o=OrderedDict([('A', 123), ('B', 124), ('C', 125), ('D', 126)])
Here is my OrderedDict
o=OrderedDict([('xmllist', 123), ('A', 124), ('B', 125), ('C', 126), ('D', 127)])
How can i interchange its keys and values as ,
o=OrderedDict([('A', 123), ('B', 124), ('C', 125), ('D', 126)])
>>> from collections import OrderedDict
>>> import itertools
>>>
>>> o = OrderedDict([('xmllist', 123), ('A', 124), ('B', 125), ('C', 126), ('D', 127)])
>>> OrderedDict((key1, o[key2]) for key1, key2 in zip(itertools.islice(o, 1, None), o))
OrderedDict([('A', 123), ('B', 124), ('C', 125), ('D', 126)])
映射:o['A'] = o['xmllist']
, o['B'] = o['A']
, o['C'] = o['B']
, ...