我在报告文件夹中有两个Python类,希望它们在模块文件夹中使用,已将报告文件夹创建为Python包,并在报告文件夹中添加了
__init__.py
文件,但我仍然无法访问模块内的Python文件文件夹。
我的文件夹结构:
请帮我找出错误并改正。预先感谢!
我认为你的
module_dir
文件夹还需要包含一个__init__.py
文件,否则它不会被识别为python包。然后你应该能够从 reports
包中导入你的类,如下所示:
from reports.TestClass2 import Class2
from reports.TestClass3 import Class3