JupyterLab 中单元格同时能够输出多行的方法
在 JupyterLab 中书写 Python 代码非常的方便,交互性强,并且能够书写 Markdown 文档等。但是,使用其进行多行打印输出时,要么使用 print 函数,要么把需要输出的参数都写在最后一行,这大大降低了其交互性。下面给出一种解决方法。
解决方案 1
每次在 JupyterLab 的第一行添加如下代码
| 1 | from IPython.core.interactiveshell import InteractiveShell | 
解决方案2
在配置文件中修改,这样不用每次在 JupyterLab 首行都添加代码
- 终端输入如下命令,创建 ipython_config.py 文件 - 1 - vim ~/.ipython/profile_default/ipython_config.py 
- 在文件中写入如下内容 - 1 
 2- c = get_config() 
 c.InteractiveShell.ast_node_interactivity = "all"
- 使其生效 - 1 - source ~/.ipython/profile_default/ipython_config.py 
参考链接
本博客所有文章除特别声明外,均采用 CC BY-NC-SA 4.0 许可协议。转载请注明来自 J. Xu!
 评论










