用法: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.

Python知识点: __import__的更多相关文章

  1. python知识点, float不能用 != 判断

    python知识点链接:https://github.com/taizilongxu/interview_python 搜索:python最佳事件 书单:http://lucida.me/blog/d ...

  2. python 知识点补充

    python 知识点补充 简明 python 教程 r 或 R 来指定一个 原始(Raw) 字符串 Python 是强(Strongly)面向对象的,因为所有的一切都是对象, 包括数字.字符串与 函数 ...

  3. Python知识点汇总

    */ * Copyright (c) 2016,烟台大学计算机与控制工程学院 * All rights reserved. * 文件名:text.cpp * 作者:常轩 * 微信公众号:Worldhe ...

  4. 【python】__import__

    函数定义 __import__(name, globals={}, locals={}, fromlist=[], level=-1) -> module Import a module. Be ...

  5. 零基础Python知识点回顾(一)

    如果你是小白,建议只要安装官网的python-3.7.0-amd64.exe 然后在电脑cmd命令提示符  输入检查是否已经安装pip,一般安装了python都会有的. >pip         ...

  6. Python函数 __import__()

    功能: __import__() 函数用于动态加载类和函数 .返回元组列表. 如果一个模块经常变化就可以使用 __import__() 来动态载入. __import__ 语法: __import__ ...

  7. ViewModel中C# Property自动添加OnPropertyChanged处理的小工具, 以及相应Python知识点

    在做WPFMVVM中经常会遇到一些Model.ViewModel的属性添加添加私有字段和更改通知方法来支持Binding. 比如把: public class Test {      public s ...

  8. Python知识点复习

    一.列表1.创建一个文件birthday.py,假设你要祝某人生日快乐!首先将年龄存储在变量age中,将姓名存储在变量name中,让程序输出类似“阿明,23岁生日快乐!” 例如:假设你要祝某人生日快乐 ...

  9. python知识点总结以及15道题的解析

    先看知识点总结 一.序列操作符x in s 如果x是列表s的元素,返回True,否则Falses + t 连接两个序列s和ts*n或者n*s 将序列s复制n次s[i] 返回s中第i元素s[i:j]或s ...

随机推荐

  1. Python菜鸟之路:Python基础-内置函数补充

    常用内置函数及用法: 1. callable() def callable(i_e_, some_kind_of_function): # real signature unknown; restor ...

  2. Python菜鸟之路:Python基础——函数

    一.函数 1. 简介 函数是组织好的,可重复使用的,用来实现单一,或相关联功能的代码段.函数能提高应用的模块性,和代码的重复利用率. 2. 组成 函数代码块以 def 关键词开头,后接函数名和圆括号( ...

  3. javascript中apply和call的区别

    请补充   136页  pdf  高级javascript设计

  4. python+NLTK 自然语言学习处理五:词典资源

    前面介绍了很多NLTK中携带的词典资源,这些词典资源对于我们处理文本是有大的作用的,比如实现这样一个功能,寻找由egivronl几个字母组成的单词.且组成的单词每个字母的次数不得超过egivronl中 ...

  5. android启动页延时跳转

    package com.goodness.goodness; import android.content.Context; import android.content.Intent; import ...

  6. CentOS7.x 报错 There are no enabled repos.

    地址 :http://mirrors.163.com/centos/7/os/x86_64/Packages/   wget http://mirrors.163.com/centos/7/os/x8 ...

  7. 深入理解ByteBuffer(转)

    转:http://blog.csdn.net/workformywork/article/details/26699345?utm_source=tuicool&utm_medium=refe ...

  8. float元素的父元素自适应高度

    当在对象内的盒子使用了float后,导致对象本身不能被撑开自适应高度,这个是由于浮动产生原因. 如何解决父div对象自适应高度,方法有三种. 1.对父元素设置固定高度 2.使用clear清除浮动 3. ...

  9. servlet实现验证码

    (博客内容来自:jsp使用servlet实现验证码,以下内容只是不才对原博客的摘抄以便以后翻阅使用) 一.原理: 验证码作为一个图片,在页面中为“画”出来的,它是如何画出来的呢? <生成图片&g ...

  10. ELK常用API使用方法

    以下ELK系列文章参考自http://www.tianyiqingci.com/ 总目录: Monitor API ElasticSearch聚合分析API Elasticsearch信息检索API ...