gpt4 book ai didi

如果放在模块中,Python 无法导入名称

转载 作者:太空宇宙 更新时间:2023-11-04 10:51:01 25 4
gpt4 key购买 nike

<分区>

Possible Duplicate:
How to do relative imports in Python?

我正在经历一些对我来说非常随机的事情。

我有一个类似这样的文件夹结构:

dir A
__init__.py is empty
a.py imports stuff and b.py
dir B
__init__.py is empty
b.py imports NOTHING

a.py 引发错误(无法导入名称 b)。这只发生在 b 是模块 B 的一部分时。如果我将其移出目录,则不会发生导入错误。

如有任何帮助,我们将不胜感激。我一定是忽略了什么。

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com