python OrderedDict与Dict的区别

1、而使用OrderedDict时我们需要从collections模块引入OrderedDict,Dict作为python内置的数据类型,所以可以直接使用;Python其它一些内置的数据类型,像str、int、list、tuple、dict。

2、python中字典Dict跟OrderedDict最大的区别就是:OrderedDict是有顺序的,而Dict是无序的。

从OrderedDict源代码中我们可以看出OrderedDict继承Dict,并且(Dictionary that remembers insertion order)OrderedDict记录插入的顺序。

猜你喜欢

转载自www.cnblogs.com/zoujl/p/10910578.html