2024-06-30 13:45:06 发布
网友
试图理解当另一个模块嵌套在文件夹中时如何正确使用它。我尝试使用模块的Packages section中记录的__init__.py实现一个包。我没有发现什么成功。这是文件结构。你知道吗
__init__.py
例如,我希望能够在propeller.py中引用credentials.py中包含的类。另一个用例,我想引用base.py中propeller.py的函数。期待着听到其他方法如何解决这个问题。谢谢!你知道吗
propeller.py
credentials.py
base.py
视情况而定。你的Module Search Path中的主模块是“机器”吗?如果是这样,您应该能够import the_machine.credentials。否则,add it to your sys.path或import it directly using the path.。你知道吗
import the_machine.credentials
视情况而定。你的Module Search Path中的主模块是“机器”吗?如果是这样,您应该能够
import the_machine.credentials
。否则,add it to your sys.path或import it directly using the path.。你知道吗相关问题 更多 >
编程相关推荐