以编程方式从另一台笔记本启动jupyter笔记本 [英] Starting jupyter notebook programmatically from another notebook

查看:296
本文介绍了以编程方式从另一台笔记本启动jupyter笔记本的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否可以从当前笔记本启动另一台笔记本?我知道如何创建和保存当前的笔记本,但我不能从当前的笔记本启动另一个笔记本。
%run在启动另一个笔记本时不起作用

Is it possible to start another notebook from the current notebook? I know how to create and save the current notebook but I cannot launch another notebook from the current one. %run does not work while starting another notebook

推荐答案

如果我想你知道你想要的笔记本的网址打开你可以通过以下方式打开它:

If I suppose you know the url for the notebook you want to open you could open it in the following way:

此代码应该是笔记本中的代码单元格:

This code should be a code cell in your notebook:

%%javascript
window.open('http://localhost:8888/notebooks/Name_of_the_notebook.ipynb')

如果你不知道笔记本的完整路径(url),你至少应该知道你创建的笔记本的名称。在这种情况下你可以这样做:

If you don't know the complete path (url) to the notebook you should, at least, know the name of the notebook you created. In this case you could do:

%%javascript
var name_of_the_notebook = 'Name_of_the_notebook.ipynb'
var url = window.location.href.split('/')
var newurl = url[0] + '//'
for (var i = 1; i < url.length - 1; i++) {
    console.log(url[i], newurl)
    newurl += url[i] + '/'
}
newurl += name_of_the_notebook
window.open(newurl)

也许浏览器会询问您是否要打开新标签页。

Maybe the browser will ask if you want to open the new tab.

这篇关于以编程方式从另一台笔记本启动jupyter笔记本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆