小编Anv*_*esh的帖子

如何按值对字典进行排序?

我有一个从数据库中的两个字段读取的值字典:字符串字段和数字字段.字符串字段是唯一的,因此这是字典的键.

我可以对键进行排序,但是如何根据值进行排序?

注意:我已阅读Stack Overflow问题如何按Python中字典的值对字典列表进行排序?并且可能可以更改我的代码以获得字典列表,但由于我不需要字典列表,我想知道是否有更简单的解决方案.

python sorting dictionary

3424
推荐指数
31
解决办法
249万
查看次数

解决环境:失败

当我尝试安装 OpenCV3 时,它显示此错误,并且正在安装其他库...

(base) C:\WINDOWS\system32>conda install -c menpo opencv3
Collecting package metadata (current_repodata.json): done
Solving environment: failed
Collecting package metadata (repodata.json): done
Solving environment: failed

UnsatisfiableError: The following specifications were found to be incompatible with each other:

  - _ipyw_jlab_nb_ext_conf -> ipywidgets -> widgetsnbextension[version='>=1.2.3'] -> notebook[version='>=4.2.0'] -> nbconvert -> bleach
  - bleach
  - ipywidgets -> widgetsnbextension[version='>=1.2.3'] -> notebook[version='>=4.2.0'] -> nbconvert -> bleach
  - jupyterlab -> jupyterlab_server[version='>=0.2.0,<0.3.0'] -> notebook -> nbconvert -> bleach
  - jupyterlab_server -> notebook -> nbconvert -> bleach
  - …
Run Code Online (Sandbox Code Playgroud)

environment failed-installation python-3.x anaconda opencv3.0

3
推荐指数
1
解决办法
8004
查看次数