英文文档:
__import__
(name, globals=None, locals=None, fromlist=(), level=0)
This function is invoked by the import
statement. It can be replaced (by importing the builtins
module and assigning to builtins.__import__
) in order to change semantics of the import
statement, but doing so is strongly discouraged as it is usually simpler to use import hooks (see PEP 302) to attain the same goals and does not cause issues with code which assumes the default import implementation is in use. Direct use of