简体   繁体   English

将文件导入其他目录[PYTHON]

[英]Importing files in a different directory [PYTHON]

Say I have an example project with the following structure: 说我有一个具有以下结构的示例项目:

-app
    -venv (dir)
    -randomPythonFile.py
    -myPythonFiles (dir)
        -helloworld.py

I want to import the file helloworld.py - I know I have to add the directory myPythonFiles to the interpreter path which I can do easily, but how do I push those changes to git so others don't have to manually add it to their paths? 我想导入文件helloworld.py-我知道我必须将目录myPythonFiles添加到我可以轻松完成的解释器路径中,但是如何将这些更改推送到git,这样其他人就不必手动将其添加到路径?

您需要在目录中有一个__init__.py文件。

from myPythonFiles import helloworld

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM