How to convert IPython notebooks to PDF and HTML?

前端 未结 18 1359
有刺的猬
有刺的猬 2020-12-12 10:49

I want to convert my ipython-notebooks to print them, or simply send them in html format. I have noticed that there exists a tool to do that already, nbconvert. Although I h

18条回答
  •  南方客
    南方客 (楼主)
    2020-12-12 11:24

    The plain python version of partizanos's answer.

    • open Terminal (Linux, MacOS) or get to point where you can execute python files in Windows
    • Type the following code in a .py file (say tejas.py)
    import os
    
    [os.system("jupyter nbconvert --to pdf " + f) for f in os.listdir(".") if f.endswith("ipynb")]
    
    • Navigate to the folder containing the jupyter notebooks
    • Ensure that tejas.py is in the current folder. Copy it to the current folder if necessary.
    • type "python tejas.py"
    • Job done

提交回复
热议问题