from . import * from module

后端 未结 3 945
粉色の甜心
粉色の甜心 2021-01-01 18:10

There is a script in the working directory which I can access with:

from . import core.py

I would also like to import * from core.py. How

3条回答
  •  独厮守ぢ
    2021-01-01 18:26

    see https://docs.python.org/2/tutorial/modules.html

    In section 6.4.2. Intra-package References:

    • If the import module in the same dir, use e.g: from . import core
    • If the import module in the top dir, use e.g: from .. import core
    • If the import module in the other subdir, use e.g: from ..other import core

    Note: Starting with Python 2.5, in addition to the implicit relative imports, you can write explicit relative imports with the from module import name form of import statement. These explicit relative imports use leading dots to indicate the current and parent packages involved in the relative import. From the surround module.

提交回复
热议问题