Python 如何在jupyter中正确导入py文件,并访问在该py文件中也导入的模块?

Python 如何在jupyter中正确导入py文件,并访问在该py文件中也导入的模块?,python,import,module,jupyter-notebook,jupyter,Python,Import,Module,Jupyter Notebook,Jupyter,我对python并不陌生,但不知何故,我从未使用过这种机制: 例如: 我有一个python文件test.py,它看起来像: '''test.py''' from anothertest import anothertestfunc def test(a): return a 如果我将该文件导入jupyter笔记本,如: [1] import test 如何在jupyter中加载另一个TestFunc模块,以便像这样使用它 [1] import test [2] anothertestf

我对python并不陌生,但不知何故,我从未使用过这种机制: 例如: 我有一个python文件test.py,它看起来像:

'''test.py'''
from anothertest import anothertestfunc
def test(a):
   return a
如果我将该文件导入jupyter笔记本,如:

[1] import test
如何在jupyter中加载另一个TestFunc模块,以便像这样使用它

[1] import test
[2] anothertestfunc
现在我只得到了一条错误消息“anotherfunc未定义”,这对我来说完全有意义。但是导入py文件的正确方法是什么呢?py文件中也有导入的模块,所以我使用在jupyter中加载的模块


提前感谢

您可以在这里或
测试中找到答案。是否还有其他测试功能