"有序"字典:按照写入字典的先后顺序排序的字典(比list优点是按键查询)
#-*-coding:utf-8 -*-
#"有序"字典:按照写入字典的先后顺序排序的字典(比list优点是按键查询)
from collections import OrderedDict
d = OrderedDict()
f = {}
l = [i for i in range(10)]
for x in "ABCDEFGHIJ":
i = l.pop()
d[x],f[x] = i,i print(type(d))
print(d)
print("-----------------------")
print(type(f))
print(f)
运行截图: