感谢Thomas,这是我一直在寻找的解决方案:
from IPython.core.interactiveshell import InteractiveShellInteractiveShell.ast_node_interactivity = "all"

感谢Thomas,这是我一直在寻找的解决方案:
from IPython.core.interactiveshell import InteractiveShellInteractiveShell.ast_node_interactivity = "all"