中提到的建议如何在 IPython Notebook 中隐藏一个特定单元格(输入或输出)?不工作。
在 Windows 上我执行以下操作
jupyter nbconvert a.ipynb --TagRemovePreprocessor.remove_cell_tags="{'remove_cell'}"
但出现错误
traitlets.traitlets.TraitError: The 'remove_cell_tags' trait of a TagRemovePreprocessor instance must be a set, but a value of type 'unicode' (i.e. u"{'remove_cell'}") was specified.
我也尝试过“{”remove_cell”}”
我正在使用 nbconvert 5.4.0
有什么想法如何做到这一点?
您需要在调用 TagRemovePreprocessor 之前启用它。
下面的代码显示了如何启用它以及如何将标签包含为列表,以便您可以根据需要排除多个标签。要排除单个标签,只需在列表中放入一个元素,例如 ['remove_cell']。
如果要转换为 html,则不需要参数 --to html(因为 html 是默认值)。例如,如果要转换为python,请将--to html更改为--to python
jupyter nbconvert a.ipynb --TagRemovePreprocessor.enabled=True --TagRemovePreprocessor.remove_cell_tags="['remove_cell', 'other_tag_to_remove']" --to html
请注意,TagRemovePreprocessor 仅在 nbconvert 5.3 及更高版本中可用:https://nbconvert.readthedocs.io/en/latest/changelog.html?highlight=TagRemovePreprocessor
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)