📜  如何导入包中的所有模块 python 代码示例

📅  最后修改于: 2022-03-11 14:45:37.264000             🧑  作者: Mango

代码示例1
from os.path import dirname, basename, isfile, join
import glob
modules = glob.glob(join(dirname(__file__), "*.py"))
__all__ = [ basename(f)[:-3] for f in modules if isfile(f) and not f.endswith('__init__.py')]