Print original input order of dictionary in python

后端 未结 5 730
你的背包
你的背包 2021-01-11 10:56

How do I print out my dictionary in the original order I had set up?

If I have a dictionary like this:

smallestCars = {\'Civic96\':          


        
5条回答
  •  遥遥无期
    2021-01-11 11:38

    >>> for car in sorted(smallestCars.items(),key=lambda x:x[1]):
    ...     print car[0]
    ... 
    Civic96
    Camry98
    Sentra98
    

提交回复
热议问题