gpt4 book ai didi

python - 如何直接从终端创建和打开 jupyter notebook ipynb 文件

转载 作者:IT老高 更新时间:2023-10-28 22:05:47 25 4
gpt4 key购买 nike

命令 jupyter notebook 将打开 Jupyter 目录树页面,您可以在其中创建 ipynb 文件。

有没有办法跳过该页面并直接在浏览器上创建和打开 ipynb 文件?

我在想类似 jupyter notebook mynotebook.ipynb 之类的东西

最佳答案

在浏览器中打开笔记本

jupyter notebook <notebook>.ipynb

创建空的、最小的笔记本:

"""create-notebook.py
Creates a minimal jupyter notebook (.ipynb)
Usage: create-notebook <notebook>
"""
import sys
from notebook import transutils as _
from notebook.services.contents.filemanager import FileContentsManager as FCM

try:
notebook_fname = sys.argv[1].strip('.ipynb')
except IndexError:
print("Usage: create-notebook <notebook>")
exit()

notebook_fname += '.ipynb' # ensure .ipynb suffix is added
FCM().new(path=notebook_fname)

别名创建笔记本脚本:

alias create-notebook='python $(pwd)/create-notebook.py'

把它们放在一起

create-notebook my_notebook && jupyter notebook my_notebook.ipynb

关于python - 如何直接从终端创建和打开 jupyter notebook ipynb 文件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48946639/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com