问题
I want Jupyter to print all the interactive output without resorting to print, not only the last result. How to do it?
Example :
a=3
a
a+1
I would like to display
3
4
回答1:
Thanks to Thomas, here is the solution I was looking for:
from IPython.core.interactiveshell import InteractiveShell
InteractiveShell.ast_node_interactivity = "all"
回答2:
https://www.dataquest.io/blog/jupyter-notebook-tips-tricks-shortcuts/
1) Place this code in a Jupyter cell:
from IPython.core.interactiveshell import InteractiveShell
InteractiveShell.ast_node_interactivity = "all"
2) In Windows, the steps below makes the change permanent. Should work for other operating systems. You might have to change the path.
C:\Users\your_profile\\.ipython\profile_default
Make a ipython_config.py file in the profile_defaults with the following code:
c = get_config()
c.InteractiveShell.ast_node_interactivity = "all"
来源:https://stackoverflow.com/questions/36786722/how-to-display-full-output-in-jupyter-not-only-last-result