python如何处理具有相同名称的模块和包? [英] How python deals with module and package having the same name?
本文介绍了python如何处理具有相同名称的模块和包?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
假设我有一个模块foo.py
和一个包foo/
.如果我打电话
Suppose I have a module foo.py
and a package foo/
. If I call
import foo
将加载哪个?如何指定我要加载模块或软件包?
which one will be loaded? How can I specify I want to load the module, or the package?
推荐答案
我相信程序包将始终被加载.据我所知,您无法解决此问题.因此,请更改软件包或模块名称.文件: http://docs.python.org/tutorial/modules .html#the-module-search-path
I believe the package will always get loaded. You can't work around this, as far as I know. So change either the package or the module name. Docs: http://docs.python.org/tutorial/modules.html#the-module-search-path
这篇关于python如何处理具有相同名称的模块和包?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文