【发布时间】:2020-12-26 06:53:39
【问题描述】:
Google 的 colab 和 jupyter notebook 对 dict() 函数的反应不同
Jupyter 笔记本:
!python --version
Python 3.7.6
代码:
trial=[(1, 250), (3, 275), (5, 290), (2, 300), (4, 500)]
dict(trial)
输出:
{1: 250, 3: 275, 5: 290, 2: 300, 4: 500}
Google Colab:
!python --version
Python 3.6.9
代码:
trial=[(1, 250), (3, 275), (5, 290), (2, 300), (4, 500)]
dict(trial)
输出:
{1: 250, 2: 300, 3: 275, 4: 500, 5: 290}
你觉得为什么会有这样的区别,会不会也是版本问题?
【问题讨论】:
-
字典未排序。
标签: python jupyter-notebook google-colaboratory