2018-10-26
閱讀量:
12986
如何設(shè)置jupyter notebook多行輸出?
看到網(wǎng)上有代碼截圖,jupyter notebook可以多行輸出,怎么設(shè)置呢?

1、臨時方法
在notebook執(zhí)行代碼之前首先需要先執(zhí)行下面代碼以設(shè)置InteractiveShell.ast_node_interactivity參數(shù)
from IPython.core.interactiveshell import InteractiveShell
InteractiveShell.ast_node_interactivity = "all"
這個方法的作用范圍僅限當(dāng)前kernel(一個.ipynb文件對應(yīng)一個kernel)
2、永久方式-更改配置文件
創(chuàng)建 配置文件 ipython-config.py ipython-kernel-config.py
ipython profile create
輸入命令后創(chuàng)建了兩個配置文件,終端打印信息中有文件的完整路徑信息

使用文本編輯器編輯ipython_config.py,Ctrl + F 查找 c.InteractiveShell.ast_node_interactivity ,將'last_expr'改為''all。注意將此行前的井號去掉,不然這行還是被注釋的。然后保存文件重啟jupyter notebook。







推薦帖子
0條評論
0條評論
0條評論