一、甚至当前文件有效
执行:
from IPython.core.interactiveshell import InteractiveShell
InteractiveShell.ast_node_interactivity = "all"
二、永久更改方法:
1 cmd命令行中执行 jupyter notebook --generate-config 生成配置文件
2 然后去 C:\Users\Administrator.ipython\profile_default 新建一个.py文件(可以用pycharm直接生成或者用jupyter notebook 写好另存为py文件),文件名为:ipython_config.py
3 文件内容为
c = get_config()
c.InteractiveShell.ast_node_interactivity = "all"
4 保存,关闭文件。
5 重启 Jupyter notebook 后,即可直接多行结果输出。