The __init__.py files are required to make Python treat the directories as containing packages; this is done to prevent directories with a common name, such as string, from unintentionally hiding valid modules that occur later on the module search path. In the simplest case, __init__.py can just be an empty file, but it can also execute initialization code for the package or set the __all__ variable, described later.
空文件是perfectly fine:
根据您的计划,这是一个从包中的模块导入公共内容的好地方,这样人们就可以简单地使用
from yourpackage import whatever
,而不必使用from yourpackage.somemodule import whatever
。相关问题 更多 >
编程相关推荐