Jupyter 简明教程

Jupyter Notebook - Types of Cells

Jupyter Notebook 中的单元格有三种类型 − Code, MarkdownRaw

Cells in Jupyter notebook are of three types − Code, Markdown and Raw.

Code Cells

此单元格中的内容将作为当前内核的编程语言中的语句处理。默认内核为 Python。所以,我们可以在代码单元格中写 Python 语句。当此单元格运行时,它的结果将显示在一个输出单元格中。输出可能是文本、图片、matplotlib 图表或 HTML 表格。代码单元格具有富文本功能。

Contents in this cell are treated as statements in a programming language of current kernel. Default kernel is Python. So, we can write Python statements in a code cell. When such cell is run, its result is displayed in an output cell. The output may be text, image, matplotlib plots or HTML tables. Code cells have rich text capability.

Markdown Cells

这些单元格包含使用 markdown 语言格式化的文本。可以使用所有类型的格式化功能,如加粗和倾斜文本、显示有序或无序列表、呈现表格化内容等。Markdown 单元格特别适用于为 notebook 的计算过程提供文档。

These cells contain text formatted using markdown language. All kinds of formatting features are available like making text bold and italic, displaying ordered or unordered list, rendering tabular contents etc. Markdown cells are especially useful to provide documentation to the computational process of the notebook.

Raw Cells

原始单元格中的内容未由 notebook 内核评估。当通过 nbconvert 传递时,它们将按需要呈现。如果您在原始单元格中输入 LatEx,则在应用 nbconvert 后将进行渲染。

Contents in raw cells are not evaluated by notebook kernel. When passed through nbconvert, they will be rendered as desired. If you type LatEx in a raw cell, rendering will happen after nbconvert is applied.

raw cells