小编Mic*_*err的帖子

在 Python 3 中使用 lambda 进行排序

这段代码适用于 Python 2.7,我如何在 Python 3 中完成这项工作?

arestas = dict()
edges = arestas.items()
edges.sort(key=lambda x: x[1])
Run Code Online (Sandbox Code Playgroud)

返回的错误是:

AttributeError: 'dict_items' 对象没有属性 'sort'

谢谢!

sorting lambda dictionary python-2.7 python-3.x

4
推荐指数
1
解决办法
1万
查看次数

标签 统计

dictionary ×1

lambda ×1

python-2.7 ×1

python-3.x ×1

sorting ×1