用`--to script`忽略`jupyter nbconvert`中的markdown单元 [英] ignore markdown cells in `jupyter nbconvert` with `--to script`

查看:347
本文介绍了用`--to script`忽略`jupyter nbconvert`中的markdown单元的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否可以让jupyter nbconvert ... --to script忽略降价单元,而不是将其转换为注释?

Is it possible to have jupyter nbconvert ... --to script ignore markdown cells rather than convert them to comments?

我之所以问是因为我想使用flake8来检查生成的Python代码,但是我不想包含markdown单元格(例如,因为它们通常是长行,并且我不想flake8抱怨他们).

I'm asking because I want to use flake8 to check the Python code that's generated but I don't want to include the markdown cells (for example, because they are often long lines, and I don't want flake8 to complain about them).

推荐答案

有命令行参数PythonExporter.exclude_markdown可以满足您的需求.要获取仅查看代码单元的pep8错误列表,我运行

There is the command line argument PythonExporter.exclude_markdown that does what you want. To get a list of pep8 errors that just look at the code cells, I run

jupyter nbconvert my_notebook.ipynb --stdout --to python --PythonExporter.exclude_markdown=True | flake8 - --ignore=W391

这篇关于用`--to script`忽略`jupyter nbconvert`中的markdown单元的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆