dict的键值对是无序的.

ordereddict是可以记录键值对的插入顺序的dict.

from collections import OrderedDict

od = OrderedDict()
od["a"] = 10
od["c"] = 20
od["b"] = 40
for k, v in od.items():
    print(k + " : " + str(v))

Copyright © 李振超 2018 all right reserved,powered by Gitbook
该文件最后修订时间: 2018-02-25 07:12:09

results matching ""

    No results matching ""