[英]How to access variables defined in one ipynb file into another in jupyter notebook?
I want to access variables defined in one ipynb file into another in jupyter notebook.我想将一个 ipynb 文件中定义的变量访问到 jupyter notebook 中的另一个文件中。 My code:
我的代码:
mymodel.ipynb
import import_ipynb
import utils
N = 12
utils.ipynb
x, sr = librosa.load(path)
S = librosa.stft(x, N)
Error:错误:
NameError: name 'N' is not defined
I have also tried我也试过
from utils import *
it can be done in the following way它可以通过以下方式完成
In source jupyter notebook file, define the variables with value eg: userName = 'PriyabrataSamantaray'在源 jupyter notebook 文件中,使用值定义变量,例如:userName = 'PriyabrataSamantaray'
In the other destination Jupyter notebook, call the file as below %run /Users/priyabrata.samantaray/ConnString --> here the connString is the name of my source jupyter notebook getusername = userName print(getusername)在另一个目标 Jupyter 笔记本中,调用如下文件 %run /Users/priyabrata.samantaray/ConnString --> 这里的 connString 是我的源 jupyter 笔记本的名称 getusername = userName print(getusername)
the output in the destination Jupyter notebook will be PriyabrataSamantaray This code can be used in Databricks jupyter notebook目标 Jupyter notebook 中的输出将是 PriyabrataSamantaray 此代码可用于 Databricks jupyter notebook
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.