在处理某些旧版Python软件包时,我注意到有一个子软件包 shadowing 一个同名模块。这是显示问题的简化文件层次结构:
t/
t/__init__.py
t/u/
t/u.py
t/u/__init__.py
如您所见,有一个python模块t/u.py
和一个子包t/u/
,看起来像是标准import
语句加载了该子包:
$ python3
Python 3.5.2 (default,Oct 8 2019,13:06:37)
[GCC 5.4.0 20160609] on linux
Type "help","copyright","credits" or "license" for more information.
>>> import t.u
__init__.py
>>>
但是,有没有一种方法可以导入模块t/u.py
?