2015-07-11 109 views

回答

0

我會想找出見https://gist.github.com/disarticulate/d06069ff3e71cf828e5329beab8cb084

在那裏,你可以看到一個很好的例子:

// a very basic output handling 
var handle_output = function (data) {console.log(data);} 

//callbacks is an object whose so special, it appears to only have been documented in 
//the source code, as no only google found me a link. 
//callbacks.iopub.output is used to get the data from execute 
var callbacks = { 
     iopub : { 
      output : handle_output, 
    } 
} 

//execute anything you want; if a string value is returned 
//you can print it out and pass it to the callbacks 
//(or do other things, no idea, it's poorly documented online 
//(read the source F12->static/notebook/js/services/kernels/kernel.js) 
//kernel.js/Kernel.prototype.execute 
var kernel = IPython.notebook.kernel; 
kernel.execute("print(json.dumps(python_dict))",callbacks) 

您CA n參見/static/services/kernels/kernel.js中的定義