Can a jupyter notebook find its own filename?
问题 Is it possible for a jupyter notebook to get the name of its own file, similarly to what we would do from a python script? os.path.basename(__file__) doesn't seem to work, at least for me on jupyterlab sys.argv[0] returns my_home/anaconda3/lib/python3.6/site-packages/ipykernel_launcher.py 回答1: The only way I've found is through JavaScritp as in this answer. The compact form is a cell like this: %%javascript IPython.notebook.kernel.execute(`notebookName = '${window.document.getElementById(