相关疑难解决方法(0)

dicts在python 3中是不可订购的?

为什么dicts可以在python2中订购,但在python3中却没有?我在文档中的任何地方都找不到它.

Python 3.3.4 (default, Feb 11 2014, 16:14:21)
>>> sorted([{'a':'a'},{'b':'b'}])
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
TypeError: unorderable types: dict() < dict()
Run Code Online (Sandbox Code Playgroud)

Python 2.7.6 (default, Feb 26 2014, 12:01:28)
>>> sorted([{'a':'a'},{'b':'b'}])
[{'a': 'a'}, {'b': 'b'}
Run Code Online (Sandbox Code Playgroud)

python sorting dictionary python-2.x python-3.x

5
推荐指数
2
解决办法
6259
查看次数

标签 统计

dictionary ×1

python ×1

python-2.x ×1

python-3.x ×1

sorting ×1