gpt4 book ai didi

python - 在 IPython Notebooks 之间共享数据

转载 作者:IT老高 更新时间:2023-10-28 20:45:47 32 4
gpt4 key购买 nike

如果我在同一台服务器上运行多个 IPython 笔记本。有没有办法在他们之间共享数据?例如,从另一个笔记本导入变量?谢谢!

最佳答案

这对我有用:

The %store command lets you pass variables between two different notebooks.

data = 'this is the string I want to pass to different notebook' %store data

Now, in a new notebook… %store -r data print(data) this is the string I want to pass to different notebook

我已经成功测试了 sklearn 数据集:

from sklearn import datasets

dataset = datasets.load_iris()

%store dataset

在笔记本中读取数据:

%store -r dataset

源代码:https://www.dataquest.io/blog/jupyter-notebook-tips-tricks-shortcuts/

关于python - 在 IPython Notebooks 之间共享数据,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31621414/

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