📅  最后修改于: 2023-12-03 15:02:28.067000             🧑  作者: Mango
Jupyter nbconvert is a command-line tool that allows you to convert Jupyter notebooks (.ipynb files) to various other formats, including:
This is particularly useful if you want to share your notebook with someone who doesn't have Jupyter installed, or if you want to include your notebook in a document or presentation.
To use nbconvert, simply open a terminal or command prompt and navigate to the directory that contains your notebook. Then, type the following command:
jupyter nbconvert --to FORMAT notebook.ipynb
Replace "FORMAT" with the desired output format (e.g., "markdown", "html", "pdf"), and replace "notebook.ipynb" with the name of your notebook file.
By default, nbconvert will save the output file in the same directory as the original notebook, with the same name but with the appropriate file extension. You can specify a custom output file name and location using the "--output" option:
jupyter nbconvert --to FORMAT --output output_file OUTPUT_LOCATION/notebook.ipynb
Nbconvert has several other options that allow you to customize the output format, including:
You can see a full list of options by typing "jupyter nbconvert --help".
If you want to convert your notebook to Markdown format, you can use the following command:
jupyter nbconvert --to markdown notebook.ipynb
This will create a Markdown file with the same name as your notebook, but with the ".md" file extension.
Markdown output includes cell input and output, as well as markdown cells. Code cells are enclosed in triple backticks, like this:
print("Hello, world!")
Markdown cells are enclosed in HTML-style tags:
<h1>This is a heading</h1>
Jupyter nbconvert is a powerful tool that allows you to easily convert your notebooks to various formats. Whether you're sharing your work with others or incorporating it into a larger document or presentation, nbconvert can help you create professional-looking output with minimal effort.