get max n values in dict py
import heapq
from operator import itemgetter
n = 3
items = {'a': 7, 'b': 12, 'c': 9, 'd': 0, 'e': 24, 'f': 10, 'g': 24}
topitems = heapq.nlargest(n, items.items(), key=itemgetter(1)) # Use .iteritems() on Py2
topitemsasdict = dict(topitems)