python - 如何在 jupyter 中正确导入 py 文件并访问在此 py 文件中也导入的模块?
问题描述
我对 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 is not defined”。但是如何正确导入一个py文件,里面也导入了模块,所以我在jupyter中加载后使用这些模块?
提前致谢
解决方案
推荐阅读
- python - 在不影响第一个迭代器的情况下使用不同的迭代器继续迭代器
- java - 如何从基于 Spring 安全的应用程序创建访问表?
- python-3.x - 迭代http请求头
- node.js - Firebase 管理员未能获取有效的 Google OAuth2 访问令牌 - 无法验证证书
- php - PHP $_POST 变量变量不起作用
- javascript - 我可以在 Dialogflow 的内联编辑器中使用意图参数吗?
- django - Django:多个管理页面使用相同的模型但不同的身份验证模式
- android - 扩展 RoomDatabase 的 Singleton Kotlin 类只被调用一次
- algorithm - C - 嵌套循环的时间复杂度
- scala - 如何对应用于输入的验证规则进行单元测试