我有这个问题,并试图在线找到解决方案。 虽然我找到了一些解决方案,但它们仍然存在一些问题,例如,当您从仪表板启动新笔记本时,会出现恼人的~/.jupyter/jupyter_notebook_config.py自动创建。
所以最终我写了自己的解决方案:
import io
import os
import re
from nbconvert.exporters.script import ScriptExporter
from notebook.utils import to_api_path
def script_post_save(model, os_path, contents_manager, **kwargs):
"""Save a copy of notebook to the corresponding language source script.
For example, when you save a `foo.ipynb` file, a corresponding `foo.py`
python script will also be saved in the same directory.
However, existing config files I found online (including the one written in
the official documentation), will also create an `Untitile.txt` file when
you create a new notebook, even if you have not pressed the "save" button.
This is anno