2025-03-14 21:59:59 -06:00
|
|
|
# jupytext
|
|
|
|
|
|
|
|
|
|
> 将 Jupyter 笔记本转换为纯文本文件,然后再转换回去。
|
2026-02-18 06:55:01 -07:00
|
|
|
> 更多信息:<https://jupytext.readthedocs.io/en/latest/using-cli.html>。
|
2025-03-14 21:59:59 -06:00
|
|
|
|
|
|
|
|
- 将笔记本转换为成对的 `.ipynb`/`.py` 笔记本:
|
|
|
|
|
|
2026-02-18 06:55:01 -07:00
|
|
|
`jupytext --set-formats ipynb,py {{notebook}}.ipynb`
|
2025-03-14 21:59:59 -06:00
|
|
|
|
|
|
|
|
- 将笔记本转换为 `.py` 文件:
|
|
|
|
|
|
2026-02-18 06:55:01 -07:00
|
|
|
`jupytext --to py {{notebook}}.ipynb`
|
2025-03-14 21:59:59 -06:00
|
|
|
|
|
|
|
|
- 将 `.py` 文件转换为没有输出的笔记本:
|
|
|
|
|
|
2026-02-18 06:55:01 -07:00
|
|
|
`jupytext --to notebook {{notebook}}.py`
|
2025-03-14 21:59:59 -06:00
|
|
|
|
|
|
|
|
- 将 `.md` 文件转换为笔记本并运行它:
|
|
|
|
|
|
2026-02-18 06:55:01 -07:00
|
|
|
`jupytext --to notebook --execute {{notebook}}.md`
|
2025-03-14 21:59:59 -06:00
|
|
|
|
|
|
|
|
- 更新笔记本中的输入单元格并保留输出和元数据:
|
|
|
|
|
|
2026-02-18 06:55:01 -07:00
|
|
|
`jupytext --update --to notebook {{notebook}}.py`
|
2025-03-14 21:59:59 -06:00
|
|
|
|
|
|
|
|
- 更新笔记本的所有配对表示:
|
|
|
|
|
|
2026-02-18 06:55:01 -07:00
|
|
|
`jupytext {{[-s|--sync]}} {{notebook}}.ipynb`
|