这段代码将为我提供运行它的Ipython笔记本的名称,
# Create a variable in Javascript that we use in Python
display(Javascript('IPython.notebook.kernel.execute("theNotebook = " + "\'"+IPython.notebook.notebook_name+"\'");'))
theNotebook
但是我必须在给出正确答案之前执行该单元2-3次。我第一次运行它时得到:
---------------------------------------------------------------------------
NameError Traceback (most recent call last)
<ipython-input-3-e65ff4ccad73> in <module>()
1 # Create a variable in Javascript that we use in Python
2 display(Javascript('IPython.notebook.kernel.execute("theNotebook = " + "\'"+IPython.notebook.notebook_name+"\'");'))
----> 3 theNotebook
NameError: name 'theNotebook' is not defined
然后我第二次得到:
'techela.ipynb'
我做错了吗?