jupyter notebook 输出python多个变量的值

jupyter 的一个 cell 默认输出最后一个变量的值,如果需要输出多个变量的值,除了使用 print 函数,还可以通过修改 ast_node_interactivity 选项来实现:

1
2
from IPython.core.interactiveshell import InteractiveShell
InteractiveShell.ast_node_interactivity = 'all'

效果如下图

jupyter-bianliang