为什么JupyterLab提供的输出与Shell不同?

时间:2019-07-03 06:51:03

标签: python jupyter-notebook python-idle jupyter-lab

在Jupyter Lab中,type('some_text')返回str,在空闲时返回<class 'str'>

1 个答案:

答案 0 :(得分:1)

IDLE不变地显示python生成的字符串表示形式。这是设计决定。启动交互式python并输入相同的内容,或在命令提示符下运行python -c "print(type(''))。同样,Python中的type(1)type([])type(lambda: None)<class 'int'><class 'list'><class 'function'>,因此是IDLE。

Jupiter Lab没有相同的约束,我认为在后一种情况下,它将输出减少到intlistfunction。 (使用re非常容易。)我认为他们的想法就像“当用户键入'type'时,他们知道他们将获得一个类,因此没有理由这么说。”

相关问题