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

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

 

python OrderedDict与Dict的区别

 

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

 

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2021-08-30
  • 2022-02-26
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2021-08-09
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-10-26
  • 2021-12-22
  • 2022-01-11
相关资源
相似解决方案