zoukankan      html  css  js  c++  java
  • Python知识点: __import__

    用法:libvirt = __import__('libvirt')

    help(__import__)

    __import__(...)
        __import__(name, globals={}, locals={}, fromlist=[], level=-1) -> module
        

      导入一个模块。

      globals:决定上下文,不修改。

      locals:当前未使用。

      fromlist:有值表示``from name import ...'',为空表示``import name''。

      当从一个包中导入模块时,注意__import__('A.B', ...)当fromlist为空时返回包A,

      不为空时返回子模块B。

      level:用于决定是否执行绝对导入。-1是绝对相对都会尝试,默认。0是绝对。正数

      表示相对当前模块的父目录的层数。


        Import a module.  The globals are only used to determine the context;
        they are not modified.  The locals are currently unused.  The fromlist
        should be a list of names to emulate ``from name import ...'', or an
        empty list to emulate ``import name''.
        When importing a module from a package, note that __import__('A.B', ...)
        returns package A when fromlist is empty, but its submodule B when
        fromlist is not empty.  Level is used to determine whether to perform
        absolute or relative imports.  -1 is the original strategy of attempting
        both absolute and relative imports, 0 is absolute, a positive number
        is the number of parent directories to search relative to the current module.

  • 相关阅读:
    网站结构之扁平结构与树形结构的区分
    如何提高网站的访问速度
    CSS透明度大汇总
    Microsoft.AlphaImageLoader滤镜讲解
    浏览器的渲染原理简介
    ACM思维题训练 Section A
    CF--思维练习--CodeForces
    CF--思维练习--CodeForces
    CF--思维练习--CodeForces
    CF思维联系--CodeForces
  • 原文地址:https://www.cnblogs.com/Clisa/p/3845243.html
Copyright © 2011-2022 走看看