在多个单元格和jupyter笔记本上共享markdown代码段

时间:2017-05-04 00:21:06

标签: ipython jupyter-notebook ipython-notebook jupyter

如何在多个单元格和多个笔记本中添加markdown代码段?

理想情况下,当我更改代码段时,它会在包含它的任何地方进行更新。

1 个答案:

答案 0 :(得分:1)

Tukushan,

http://ipython.readthedocs.io/en/stable/config/extensions/storemagic.html

尝试%store命令。我无法使用函数或markdown,因此我将markdown片段存储为文本,然后在新笔记本中使用%store -r <variable>读取它。

示例:

在notebook_1中

title_var = "# Re-Useable Title"

%store title_var

  

存储'title_var'(str)

在notebook_2中

%store -r title_var