我有一个ipython混合markdown和python细胞笔记本.
我想让我的一些python细胞读取相邻的markdown细胞并将它们作为输入进行处理.
所需情况的一个例子:
CELL 1(markdown):要执行的SQL代码
CELL 2(降价):
select * from tbl where x=1CELL 3(python) :
mysql.query(ipython.previous_cell.content)
(语法ipython.previous_cell.content组成)
执行" CELL 3 "应该相当于mysql.query("select * from tbl where x=1")
如何才能做到这一点 ?
我已经为我的Jupyter笔记本创建了一个javascript扩展,它将为我绘制一些数据.现在我在扩展程序中对数据进行了硬编码.我的问题:有没有办法访问笔记本中存在的数据对象?
例如,下面是扩展的一些示例代码:
define([
'base/js/namespace'
], function(
Jupyter
) {
function test_second_extension() {
var handler = function () {
console.log(
'This is the current notebook application instance:',
Jupyter.notebook
);
var data = [{"x": 1, "y": 5}, {"x": 2, "y":12}, {"x": 3, "y": 27}];
console.log(data);
};
var action = {
icon: 'fa-comment-o', // a font-awesome class used on buttons, etc
help : 'Print notebook instance',
help_index : 'zz',
handler : handler
};
var prefix = 'test_second_extension';
var action_name = 'show-alert';
var full_action_name …Run Code Online (Sandbox Code Playgroud)