我希望Jupyter能够打印所有的交互式输出而不需要打印,而不仅仅是最后的结果。怎么做?如何在Jupyter中显示完整的输出,而不仅是最后的结果?
它并不常用,但实际上有一个配置选项,应该这样做 - 设置'InteractiveShell。在[IPython内核配置文件]
(http://ipython.readthedocs.org/en/stable/config/options/kernel.html)中将last_node_interactivity设置为all。
1 from IPython.core.interactiveshell import InteractiveShell 2 InteractiveShell.ast_node_interactivity = "all"
默认值是:'last_expr'。你可以在这里找到很多其他的选项:
http://ipython.readthedocs.org/en/stable/config/options/terminal.html
作为参考,它的选项是'all','none','last '和'last_expr'。 'last'和'last_expr'之间的区别:
如果您的单元格以含有表达式的循环结束,'last'将在循环的每次迭代中向您显示该表达式的结果。
'last_expr'(默认值)不会显示:它只会在单元格末尾显示裸露表达式的结果。
更改默认设置
https://www.dataquest.io/blog/jupyter-notebook-tips-tricks-shortcuts/
1)将此代码放置在Jupyter单元中:
1 from IPython.core.interactiveshell import InteractiveShell 2 3 InteractiveShell.ast_node_interactivity = "all"
2)在Windows中,以下步骤会使更改永久生效。应该适用于其他操作系统。您可能必须更改路径。
1 C:\Users\your_profile\\.ipython\profile_default
做一个ipython_config.py文件与下面的代码profile_defaults:
1 c = get_config() 2 3 c.InteractiveShell.ast_node_interactivity = "all"