【发布时间】:2021-11-17 22:52:31
【问题描述】:
我有一个简单的笔记本脚本:'test_a.ipynb',其中包含一个 test_a() 函数。
test_a.ipynb 在 python 脚本中调用:'test_b.py',方式如下:
get_ipython().run_line_magic('run', 'test_a.ipynb')
def test_b():
test_a()
'test_b' 然后被另一个 python 脚本调用并以下列方式执行:
from test_b import *
test_b()
错误信息是:
NameError: name 'test_a' is not defined
但以下脚本运行良好:
get_ipython().run_line_magic('run', 'test_a.ipynb')
def test_b():
test_a()
#
test_b()
感谢任何帮助。
【问题讨论】:
标签: python-3.x jupyter-notebook ipython