gpt4 book ai didi

jupyter-notebook - 将 ipython notebook 转换为 notebook 时隐藏一些单元格

转载 作者:行者123 更新时间:2023-12-04 08:30:26 29 4
gpt4 key购买 nike

在将 IPython 笔记本转换为笔记本时,我试图隐藏一些特定的单元格。我想在类里面使用笔记本,并希望从包含问题和答案的主笔记本生成“练习”笔记本。

This post非常有帮助,但由于某种原因,使用标签和预处理器的方法在将笔记本转换为笔记本时不起作用(在转换为 PDF 和 HTML 时它确实起作用)。

任何想法,提示?提前致谢!

最佳答案

使用 nbformat 非常简单(已经安装了 jupyter):

import nbformat
nb = nbformat.read('Untitled6.ipynb', as_version=4)
for cell in nb.cells.copy():
if 'remove_cell' in cell.metadata.get('tags', []):
nb.cells.remove(cell)
nbformat.write(nb, 'Untitled7.ipynb')

关于jupyter-notebook - 将 ipython notebook 转换为 notebook 时隐藏一些单元格,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51879855/

29 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com