gpt4 book ai didi

python - 为什么字典看起来是颠倒的?

转载 作者:太空宇宙 更新时间:2023-11-04 06:44:43 25 4
gpt4 key购买 nike

为什么python中的字典是颠倒的?

>>> a = {'one': '1', 'two': '2', 'three': '3', 'four': '4'}
>>> a
{'four': '4', 'three': '3', 'two': '2', 'one': '1'}

我该如何解决这个问题?

最佳答案

python 中的字典(以及一般的哈希表)是无序的。在 Python 中,您可以对键使用 sort() 方法对它们进行排序。

关于python - 为什么字典看起来是颠倒的?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2291637/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com