31.2. importlib — Convenience wrappers for __import__()

2.7 版新增。

This module is a minor subset of what is available in the more full-featured package of the same name from Python 3.1 that provides a complete implementation of import . What is here has been provided to help ease in transitioning from 2.7 to 3.1.

importlib. import_module ( 名称 , package=None )

导入模块。 name 自变量按绝对 (或相对) 术语方式指定要导入什么模块 (如 pkg.mod or ..mod )。若名称以相对术语方式指定,那么 package argument must be specified to the package which is to act as the anchor for resolving the package name (e.g. import_module('..mod', 'pkg.subpkg') 将导入 pkg.mod ). The specified module will be inserted into sys.modules and returned.

上一话题

31.1. imp — 访问 import 内部

下一话题

31.3. imputil — 导入实用程序

本页