如何通过代码将Jupyter Notebook保存为HTML? [英] How to save Jupyter Notebook to HTML by code?

查看:540
本文介绍了如何通过代码将Jupyter Notebook保存为HTML?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个Jupyter Notebook程序,可以为我做分析.运行后,我想将其另存为HTML,以便以后查看. (然后,我可以更改输入数据文件以对其他数据进行分析.)

I have a Jupyter Notebook program, which do analysis for me. After it's been run, I want to save it as HTML so I can view it later. (And then I can change the input data file to do analysis for other data.)

通常,我是手工完成的.看起来像

Typically, I do this by hand. This would look like

但这对我来说很繁琐.所以我想知道是否有任何代码可以为我做到这一点?也许像

But this feels very tedious for me. So I'm wondering if there is any code can do this for me? Maybe something like

%save_html
# or with a file_name
%save_html file_name


注意:我已经找到解决此问题的方法.但是我没有在搜索中找到太多信息,因此我将其发布在这里,它可能会帮助遇到相同问题的其他人.我将解决方案作为答案.


Note: I have figured out a workaround for this. But I didn't find too much info by search, so I post it here and it may help someone else having the same problem. I'll post my solution as an answer.

推荐答案

您应该能够在具有jupyter-notebook.exe文件的同一目录中找到脚本.名称为jupyter-nbconvert.exe.像这样运行它:

you should be able to find a script in the same directory that has the jupyter-notebook.exe file. Its name is jupyter-nbconvert.exe. Run it like this:

./jupyter-nbconvert.exe --to html 'path/to/nb.ipynb'`

文档

这篇关于如何通过代码将Jupyter Notebook保存为HTML?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆