For example, code in the A.B.C module can do:
from . import D # Imports A.B.D
from .. import E # Imports A.E
from ..F import G # Imports A.F.G
Python导入模块详解
本文介绍了在Python中如何从同一包内的不同模块导入特定组件的方法。例如,在A.B.C模块中可以使用相对导入的方式引入A.B.D、A.E及A.F.G等模块。这有助于理解Python的包结构和模块组织方式。
For example, code in the A.B.C module can do:
from . import D # Imports A.B.D
from .. import E # Imports A.E
from ..F import G # Imports A.F.G
1574
7061
1万+

被折叠的 条评论
为什么被折叠?