【发布时间】:2022-06-13 17:53:32
【问题描述】:
D:.
││
├───common
│ selenium_helper.py
│ __init__.py
│
│
├───test
│ test.py
│
我有上面的目录结构,我想将 selenium_helper 导入 test.py 我的 test.py 包含以下简单代码
from ..common.selenium_helper import options
print("hello world")
当我运行 test.py 时出现以下错误。
我浏览了许多 SO 帖子,但仍然无法完成这项工作
Traceback (most recent call last):
File "test.py", line 1, in <module>
from ..common.selenium_helper import options
ImportError: attempted relative import with no known parent package
有没有办法在不修改或附加到系统路径的情况下解决此问题
【问题讨论】:
标签: python-3.x