python有序字典

from collections import OrderedDict
od = {'c': 1, 'a': 3, 'b': 5}
for key, val in od.items():
    print(key, val)

is_od = {}
OrderedDict(is_od)
is_od['c'] = 1
is_od['a'] = 3
is_od['b'] = 5
for key, val in is_od.items():
    print(key, val)

结果;
a 3
b 5
c 1------------’
a 3
b 5
c 1

 

posted @ 2020-08-18 09:39  Fmaj-7  阅读(116)  评论(0编辑  收藏  举报