假设我使用不必要的长路径导入:
from pandas.core.series import Series更常见的导入是:
from pandas import Series我可以通过以下方式查看完整路径:
Series Out[6]: pandas.core.series.Series这是我困惑的根源。 在顶级__init__模块中没有任何地方可以from core import * (或core.series ) from core import *任何内容。 .core的__init__模块也是空的。
是什么使我能够简单地使用from pandas import Series而不是完整路径,或者更一般地说,导入一个“几级降低”的模块,函数,变量或类?
Say that I import with the unnecessarily long full path:
from pandas.core.series import SeriesThe more common import is simply:
from pandas import Seriesto which I can view the full path with:
Series Out[6]: pandas.core.series.SeriesHere is the source of my confusion. Nowhere in the top-level __init__ module is there any import of from core import * (or core.series, for that matter). The __init__ module for .core is empty also.
What enables me to be able to use simply from pandas import Series rather than the full path or, more generally, to import a module, function, variable, or class that is "several levels down"?
最满意答案
你有__init__.py文件内 :
from pandas.core.api import *其中导入Series 。
You have inside the __init__.py file:
from pandas.core.api import *in which Series is imported.
更多推荐
发布评论