Items ordering in Python dictionary

前端 未结 2 556
一整个雨季
一整个雨季 2020-12-11 19:32

I am in simple doubt... I created the following dictionary:

>>> alpha={\'a\': 10, \'b\': 5, \'c\': 11}

But, when I want to see the

2条回答
  •  情深已故
    2020-12-11 19:59

    Dictonaries are not guaranting sorting of keys. You can find this information in python docs: http://docs.python.org/tutorial/datastructures.html#dictionaries

    You can always sort dictionary keys or use other, more specialized collection.

提交回复
热议问题