时间:2021-07-01 10:21:17 帮助过:41人阅读
本文实例讲述了Python有序字典简单实现方法。分享给大家供大家参考,具体如下:
代码:
# -*- coding: UTF-8 -*- import collections print 'Regular dictionary:' d = {} d['a'] = 'A' d['b'] = 'B' d['c'] = 'C' for k, v in d.items(): print k, v print '\nOrderedDict:' d = collections.OrderedDict() d['a'] = 'A' d['b'] = 'B' d['c'] = 'C' for k, v in d.items(): print k, v
执行结果:
以上就是Python实现有序字典方法示例的详细内容,更多请关注Gxl网其它相关文章!