为什么 Jupyter 笔记本不执行所有代码行? (iPython)
Why does Jupyter notebook NOT execute all the lines of code? (iPython)
ls = [16, 81, 23, 74, 91, 612, 33, 812]
ls[2:6:3] #Starting from index 2 till index 5 and skip the next 2 indices
ls[::-1] # Reverse list is printed
只执行第 2 行,即 ls[::-1]
。我做错了什么?
它执行所有行,默认只输出最后一行。
如果你想看到所有的步骤,你可以print
你想看到的结果。
还通过要求 jupyter 通过添加
系统地显示所有输出来提供替代方案
from IPython.core.interactiveshell import InteractiveShell
InteractiveShell.ast_node_interactivity = "all"
请重新启动您的 jupyter-notebook 并刷新 jupyter。希望对你有帮助..
ls = [16, 81, 23, 74, 91, 612, 33, 812]
ls[2:6:3] #Starting from index 2 till index 5 and skip the next 2 indices
ls[::-1] # Reverse list is printed
只执行第 2 行,即 ls[::-1]
。我做错了什么?
它执行所有行,默认只输出最后一行。
如果你想看到所有的步骤,你可以print
你想看到的结果。
from IPython.core.interactiveshell import InteractiveShell
InteractiveShell.ast_node_interactivity = "all"
请重新启动您的 jupyter-notebook 并刷新 jupyter。希望对你有帮助..