在不同目录中导入文件 [PYTHON]
Importing files in a different directory [PYTHON]
假设我有一个具有以下结构的示例项目:
-app
-venv (dir)
-randomPythonFile.py
-myPythonFiles (dir)
-helloworld.py
我想导入文件 helloworld.py - 我知道我必须将目录 myPythonFiles 添加到我可以轻松完成的解释器路径,但是我如何将这些更改推送到 git 所以其他人不必手动将其添加到他们的路径中?
目录中需要一个 __init__.py
文件。
from myPythonFiles import helloworld
假设我有一个具有以下结构的示例项目:
-app
-venv (dir)
-randomPythonFile.py
-myPythonFiles (dir)
-helloworld.py
我想导入文件 helloworld.py - 我知道我必须将目录 myPythonFiles 添加到我可以轻松完成的解释器路径,但是我如何将这些更改推送到 git 所以其他人不必手动将其添加到他们的路径中?
目录中需要一个 __init__.py
文件。
from myPythonFiles import helloworld