[英]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
仅执行第二行,即ls[::-1]
。 我究竟做错了什么?
它确实执行了所有行,默认情况下它只执行最后一行 output。 如果你想看到所有的步骤,你可以print
你想看到的结果。
这个答案还通过要求 jupyter 通过添加系统地显示所有 output 来提供替代方案
from IPython.core.interactiveshell import InteractiveShell
InteractiveShell.ast_node_interactivity = "all"
请再次重新启动 jupyter-notebook 并刷新 jupyter。 希望它有帮助..
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.