在 IPython 笔记本之间共享数据 [英] Share data between IPython Notebooks
问题描述
如果我在同一台服务器上运行多个 IPython 笔记本.有没有办法在它们之间共享数据?例如,从另一个笔记本导入一个变量?谢谢!
If I have several IPython notebooks running on the same server. Is there any way to share data between them? For example, importing a variable from another notebook? Thanks!
推荐答案
这对我有用:
%store 命令允许您在两个不同的笔记本.
The %store command lets you pass variables between two different notebooks.
data = '这是我想传递给不同笔记本的字符串'%存储数据
data = 'this is the string I want to pass to different notebook' %store data
现在,在一个新笔记本中... %store -r data print(data) 这是字符串我想传递到不同的笔记本
Now, in a new notebook… %store -r data print(data) this is the string I want to pass to different notebook
我已经成功地测试了 sklearn 数据集:
I've successfully tested with sklearn dataset :
from sklearn import datasets
dataset = datasets.load_iris()
%store dataset
在笔记本中读取数据:
%store -r dataset
src : https://www.dataquest.io/blog/jupyter-notebook-tips-tricks-shortcuts/
这篇关于在 IPython 笔记本之间共享数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!