Jupyter Notebook에서 Notebook 이름 가져오기

2019. 10. 27. 16:27꿀팁 분석 환경 설정/Jupyter Notebook & Lab

728x90

가끔 주피터 노트북 이름을 가져와서 먼가 활용하고 싶을 때가 있다.

그래서 찾아보니 다음과 같이 하니 잘 작동하는 것을 확인했다!

필요하신 분은 밑에 코드를 긁어서 활용하면 된다!

%%javascript
IPython.notebook.kernel.execute(`notebookName = '${window.document.getElementById("notebook_name").innerHTML}'`);

 

https://stackoverflow.com/questions/12544056/how-do-i-get-the-current-ipython-notebook-name

 

How do I get the current IPython Notebook name

I am trying to obtain the current NoteBook name when running the IPython notebook. I know I can see it at the top of the notebook. What I am after something like currentNotebook = IPython.foo.bar.

stackoverflow.com

아니면 패키지도 있음. 그렇지만 한글은 작동 안함.

 

#!pip install ipyparams
import ipyparams
ipyparams.notebook_name

 

def current_notebook_name() :
    import ipyparams
    notebook_name = ipyparams.notebook_name
    return notebook_name
 
 
 current_notebook_name()
728x90