import nbformat
from nbconvert.preprocessors import ExecutePreprocessor
def main():
with open(notebook_filename) as f:
nb = nbformat.read(f, as_version=4)
ep = ExecutePreprocessor(timeout=600, kernel_name='python3')
ep.preprocess(nb, {'metadata': {'path': 'notebooks/'}})
with open('executed_notebook.ipynb', 'w', encoding='utf-8') as f:
nbformat.write(nb, f)
您需要从
main()
函数调用Jupyter API。大概是这样的:见Jupyter docs
相关问题 更多 >
编程相关推荐