本文介绍了如何使 Jupyter Lab 保存笔记本(以编程方式)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一个可以通宵运行的笔记本,可以打印出一堆东西,包括图像等.我想以编程方式保存此输出(可能以特定时间间隔).我还想保存运行的代码.在 Jupyter 笔记本中,您可以:
I have a notebook that runs overnight, and prints out a bunch of stuff, including images and such. I want to cause this output to be saved programatically (perhaps at certain intervals). I also want to save the code that was run. In a Jupyter notebook, you could do:
from IPython.display import display, Javascript
display(Javascript('IPython.notebook.save_checkpoint();'))
# causes the current .ipynb file to save itself (same as hitting CTRL+s)
推荐答案
您可以使用 ipylab 访问来自 Python 的 JupyterLab API.要保存笔记本,只需调用 docmanager:save
命令:
You can use ipylab to access JupyterLab API from Python. To save the notebook just invoke the docmanager:save
command:
from ipylab import JupyterFrontEnd
app = JupyterFrontEnd()
app.commands.execute('docmanager:save')
您可以使用 app.commands.list_commands()
获取完整的命令列表.
You can get the full list of commands with app.commands.list_commands()
.
这篇关于如何使 Jupyter Lab 保存笔记本(以编程方式)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!