我正在使用一些给我的python代码,并且它在我的系统上失败。特别是在from collections import OrderedDict
的资本O和资本D. 的声明但如果我更改声明为import ordereddict
它不会失败。 如果我尝试import OrderedDict
,它会失败并显示未找到错误。from collections import OrderedDict and python version
我的版本的python是每个SuSE SLES SDK 11.4 2.6.9。 我试图执行的python我相信是为Python的早期版本2.6.x编写的。
是这个问题我遇到了python版本的直接结果吗? 有没有人有任何建议如何正确解决这个问题? OrderedDict
和ordereddict
之间是否有差别,是否来自collections
?
版本2.7中的OrderedDict' [出现](https://docs.python.org/2/library/collections.html#collections.OrderedDict)。 – skovorodkin
相关:[OrderedDict为旧版本的Python](http://stackoverflow.com/questions/1617078/ordereddict-for-older-versions-of-python) – Wondercricket
阅读罚款[文档](https:// docs。 python.org/2/library/collections.html?highlight=Equivalent#collections.OrderedDict),它告诉你它在什么版本中被引入,以及在哪里可以找到**版本的**等价OrderedDict配方**。 – martineau