当前位置: 首页>>代码示例>>Python>>正文


Python _frozen_importlib._gcd_import方法代码示例

本文整理汇总了Python中_frozen_importlib._gcd_import方法的典型用法代码示例。如果您正苦于以下问题:Python _frozen_importlib._gcd_import方法的具体用法?Python _frozen_importlib._gcd_import怎么用?Python _frozen_importlib._gcd_import使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在_frozen_importlib的用法示例。


在下文中一共展示了_frozen_importlib._gcd_import方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: import_module

# 需要导入模块: import _frozen_importlib [as 别名]
# 或者: from _frozen_importlib import _gcd_import [as 别名]
def import_module(name, package=None):
    """Import a module.

    The 'package' argument is required when performing a relative import. It
    specifies the package to use as the anchor point from which to resolve the
    relative import to an absolute import.

    """
    level = 0
    if name.startswith('.'):
        if not package:
            raise TypeError("relative imports require the 'package' argument")
        for character in name:
            if character != '.':
                break
            level += 1
    return _bootstrap._gcd_import(name[level:], package, level)


#need at least one import hook for importlib stuff to work. 
开发者ID:war-and-code,项目名称:jawfish,代码行数:22,代码来源:__init__.py

示例2: import_module

# 需要导入模块: import _frozen_importlib [as 别名]
# 或者: from _frozen_importlib import _gcd_import [as 别名]
def import_module(name, package=None):
    """Import a module.

    The 'package' argument is required when performing a relative import. It
    specifies the package to use as the anchor point from which to resolve the
    relative import to an absolute import.

    """
    level = 0
    if name.startswith('.'):
        if not package:
            msg = ("the 'package' argument is required to perform a relative "
                   "import for {!r}")
            raise TypeError(msg.format(name))
        for character in name:
            if character != '.':
                break
            level += 1
    return _bootstrap._gcd_import(name[level:], package, level) 
开发者ID:awemulya,项目名称:kobo-predict,代码行数:21,代码来源:__init__.py


注:本文中的_frozen_importlib._gcd_import方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。