簡體   English   中英

為什么 Jupyter notebook 不執行所有代碼行? (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

僅執行第二行,即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.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM