如何按键对字典进行排序? - How can I sort a dictionary by key?

问题:

What would be a nice way to go from {2:3, 1:89, 4:5, 3:0} to {1:89, 2:3, 3:0, 4:5} ?{2:3, 1:89, 4:5, 3:0}{1:89, 2:3, 3:0, 4:5}什么?
I checked some posts but they all use the "sorted" operator that returns tuples.我检查了一些帖子,但它们都使用返回元组的“排序”运算符。


解决方案:

参考一: https://en.stackoom.com/question/blhd
参考二: https://stackoom.com/question/blhd
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章