给定这样的字典:
my_map = {'a': 1, 'b': 2}
如何将这张地图倒置即可:
inv_map = {1: 'a', 2: 'b'}
Python 3+:
inv_map = {v: k for k, v in my_map.items()}
Python 2:
inv_map = {v: k for k, v in my_map.iteritems()}