没有从JavaScript收到Jupyter笔记本名称

时间:2018-03-13 09:08:04

标签: javascript jupyter-notebook

当我手动在Jupyter笔记本中运行以下两个单元格时,它会打印笔记本的名称:

Cell 1

from IPython.core.magics.display import Javascript
Javascript("""
var kernel = IPython.notebook.kernel;
var body = document.body, attribs = body.attributes;
var command = "notebook_name = " + "'" + attribs['data-notebook-name'].value 
+ 
"'";
kernel.execute(command);
""")

单元格2:

print(notebook_name)

但是,当我重新启动笔记本并从菜单中选择全部运行时,未设置变量notebook_name

有谁知道发生了什么事?

我搜索了许多论坛,但我仍然不知道它会是什么......

0 个答案:

没有答案