python中字典在3.6之后是有序的,在3.6之前是无序的
这里的有序是指的是插入顺序
python2.7
Python 2.7.5 (default, Aug 4 2017, 00:39:18)
[GCC 4.8.5 20150623 (Red Hat 4.8.5-16)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> a = {"1":23,"aa":"dd","ff":"23","bb":"dd"}
>>> a
{'1': 23, 'aa': 'dd', 'bb': 'dd', 'ff': '23'}
>>> a.keys()
['1', 'aa', 'bb', 'ff']
>>>
KeyboardInterrupt
>>>
python3.8
Python 3.8.8 (default, Apr 13 2021, 15:08:03) [MSC v.1916 64 bit (AMD64)] :: Anaconda, Inc. on win32
Warning:
This Python interpreter is in a conda environment, but the environment has
not been activated. Libraries may fail to load. To activate this environment
please see https://conda.io/activation
Type "help", "copyright", "credits" or "license" for more information.
>>> a = {"1":23,"aa":"dd","ff":"23","bb":"dd"}
>>> a
{'1': 23, 'aa': 'dd', 'ff': '23', 'bb': 'dd'}
>>> a.keys()
dict_keys(['1', 'aa', 'ff', 'bb'])
>>> a.values()
dict_values([23, 'dd', '23', 'dd'])
>>>