Jupyter 简明教程

Jupyter Notebook - Cell Magic Functions

在这一章中,让我们了解单元格魔术函数及其功能。

In this chapter, let us understand cell magic functions and their functionalities.

%%html

这个单元格魔术函数将代码单元格的内容渲染为 html 脚本。

This cell magic function renders contents of code cell as html script.

html script

%%js or %%javascript

使用这个单元格魔术命令,你可以在 Jupyter 笔记本单元格中嵌入 javascript 代码。

You can embed javascript code in Jupyter notebook cell with the help of this cell magic command.

javascript code
javascript code output

%%writefile

使用这个命令将代码单元格的内容写入到文件中。

Contents of code cell are written to a file using this command.

write file