不知道这个是不是你想要的。
from collections import OrderedDict
your_dict = {19: 7, 31: 6, 28: 5, 16: 5, 32: 5, 2: 4, 24: 4, 29: 4, 6: 4, 18: 4, 15: 4, 12: 4}
order_of_keys = your_dict.keys()
list_of_tuples = [(key, your_dict[key]) for key in order_of_keys]
your_dict = OrderedDict(list_of_tuples)
print(next(reversed(your_dict)))
谢谢。只是不知道,面对以后会增加的几万 或更多的数据,
处理起来效率如何
d = {19: 7, 31: 6, 28: 5, 16: 5, 32: 5, 2: 4, 24: 4, 29: 4, 6: 4, 18: 4, 15: 4, 12: 4}
list(d)[-1]
时间复杂度O(n)