有一个包 pack,里面有__init__.py ,test.py若我在__init__.py中导入 test.py 采用
import test
运行__init__.py 没问题,但在包外 导入pack 出现问题,找不到test若采用
from . import test or from pack import test
__init__.py就找不到test,包外导入pack,就没问题,这是为什么?
认证高级PHP讲师
Pay attention to python’s module search process: https://docs.python.org/2/tut...
Run __init__.py to import test because the program runs in the current directory, that is, the pack directory is automatically added to the module search path.
Pay attention to python’s module search process: https://docs.python.org/2/tut...
Run __init__.py to import test because the program runs in the current directory, that is, the pack directory is automatically added to the module search path.