【发布时间】:2020-05-04 07:56:34
【问题描述】:
我正在做一个数据分析项目,我试图以降序排列我的结果,第一次遇到类似问题时,我使用了sorted(dictt.items(), key= lambda x: x[1]),它运行良好。现在,我遇到了一个类型错误:“AttributeError: 'set' object has no attribute 'items'”。
我做错了什么?
【问题讨论】:
-
这是一个字典:
{'one':1, 'two':2, 'three':3}这是一个集合:{'one', 1, 'two', 2, 'three', 3}。dictt是集合,不是字典 -
哦,非常感谢。我对所有这些都是新手。我还是得意忘形。
标签: python-3.x dictionary jupyter-notebook data-analysis