简体   繁体   English

如何从 Jupyter 实验室笔记本下载 .py 文件?

[英]How to download a .py file from Jupyter lab notebook?

In jupyter notebook, there is a provision to download a notebook as .py file.在 jupyter notebook 中,可以将 notebook 下载为 .py 文件。 In jupyter lab, there is an option called export as which does not contain an option to download a .py file.在 jupyter 实验室中,有一个名为 export as 的选项,其中不包含下载 .py 文件的选项。 Is there any workaround for this, instead of copying the script in the notebook and pasting it in a python file.是否有任何解决方法,而不是复制笔记本中的脚本并将其粘贴到 python 文件中。

In Jupyter lab, go to File Menu.在 Jupyter 实验室中,转到文件菜单。 Select "Export Notebook as" and then choose the "Export Notebook to Executable Script" option.选择“将笔记本导出为”,然后选择“将笔记本导出为可执行脚本”选项。

For Jupyter notebook, there is "Download as" option in File menu of Jupyter notebook.对于 Jupyter Notebook,Jupyter Notebook 的文件菜单中有“下载为”选项。 You can select Python (.py) from the list of available options.您可以从可用选项列表中选择 Python (.py)。

From the jupyter docs: ( https://jupyterlab.readthedocs.io/en/stable/user/export.html ) JupyterLab allows you to export your jupyter notebook files (.ipynb) into other file formats such as:来自 jupyter 文档:( https://jupyterlab.readthedocs.io/en/stable/user/export.html )JupyterLab 允许您将 jupyter 笔记本文件 (.ipynb) 导出为其他文件格式,例如:

Asciidoc .asciidoc

HTML .html

Latex .tex

Markdown .md

PDF .pdf

ReStructured Text .rst

Executable Script .py

Reveal.js Slides .html

To access these options, while a notebook is open, browse the File menu:要访问这些选项,请在笔记本打开时浏览文件菜单:

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM