问题描述
我使用 Jupyter Notebook 运行一系列需要一些时间的实验.某些单元格需要太多时间来执行,所以我想关闭浏览器选项卡并稍后再回来是正常的.但是当我做内核中断运行时.
I use Jupyter Notebook to run a series of experiments that take some time.Certain cells take way too much time to execute so it's normal that I'd like to close the browser tab and come back later. But when I do the kernel interrupts running.
我想有一个解决方法,但我找不到
I guess there is a workaround for this but I can't find it
推荐答案
最简单的解决方法似乎是 内置单元魔法 %%capture
:
The simplest workaround to this seems to be the built-in cell magic %%capture
:
%%capture output
# Time-consuming code here
保存,关闭标签,稍后回来.输出现在存储在 output
变量中:
Save, close tab, come back later. The output is now stored in the output
variable:
output.show()
这将显示所有临时print
结果以及普通或丰富的输出单元格.
This will show all interim print
results as well as the plain or rich output cell.
这篇关于关闭浏览器选项卡后保持 Jupyter notebook 运行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!