如何将带有单元格分隔符的 python 脚本转换为 jupyter notebook?
How to convert a python script with cell delimiters to a jupyter notebook?
我主要使用 Spyder 进行数据分析,对此我非常满意。在那里,您可以在正常的 python 脚本中使用 Jupyter Notebooks 的单元格功能,使用 # %%
来分隔各个代码单元格(以及执行块)。同样的事情也可能发生在 Atom with Hydrogen 中。
我正在寻找一种将这些脚本转换为 jupyter notebook 的方法,在每个 # %%
处自动拆分单元格。我将通过插入一些降价并可能另存为 pdf 或 html.
来记录、解释和分享我的工作流程的笔记本
可以自动转换吗? nbconvert
是否可行? (我只是反过来使用它:jupyter -> python)
有 jupytext
(also available on pypi) 可以从 ipynb
转换为多种格式并返回。
安装 jupytext
后,您可以使用
$ jupytext --to notebook test.py
为了生成test.ipynb
.
jupytext
有很多有趣的功能,可以在使用笔记本时派上用场。
除了上面的回答。另外 this I have written a while ago (I am afraid I no longer maintain it) with references from here 可能仍在工作并且对您有用。
此处 example 用于 spyder 样细胞标记。
我主要使用 Spyder 进行数据分析,对此我非常满意。在那里,您可以在正常的 python 脚本中使用 Jupyter Notebooks 的单元格功能,使用 # %%
来分隔各个代码单元格(以及执行块)。同样的事情也可能发生在 Atom with Hydrogen 中。
我正在寻找一种将这些脚本转换为 jupyter notebook 的方法,在每个 # %%
处自动拆分单元格。我将通过插入一些降价并可能另存为 pdf 或 html.
可以自动转换吗? nbconvert
是否可行? (我只是反过来使用它:jupyter -> python)
有 jupytext
(also available on pypi) 可以从 ipynb
转换为多种格式并返回。
安装 jupytext
后,您可以使用
$ jupytext --to notebook test.py
为了生成test.ipynb
.
jupytext
有很多有趣的功能,可以在使用笔记本时派上用场。
除了上面的回答。另外 this I have written a while ago (I am afraid I no longer maintain it) with references from here 可能仍在工作并且对您有用。
此处 example 用于 spyder 样细胞标记。