zoukankan      html  css  js  c++  java
  • Python Importing Modules

    Python has two ways of importing modules. Both are useful, and you should know when to use each. One way is import module,The other way is From Module Import  to accomplishes the same thing, but it has subtle and important differences.

    • From Module Import

      The attributes and methods of the imported module types are imported directly into the local namespace, so they are available directly, without qualification by module name.

    1. If you will be accessing attributes and methods often and don't want to type the module name over and over, use from module import.
    2. If you want to selectively import some attributes and methods but not others, use from module import.
    3. If the module contains attributes or functions with the same name as ones in your module, you must use import module to avoid name conflicts. 
    •  Import Module

       The attributes and methods of the imported module types are NOT imported directly into the local namespace, so they are unavailable directly, you can use it by module name.

    Work for fun,Live for love!
  • 相关阅读:
    底层原理
    No.1
    No.3
    No.0
    php 10进制转62进制,可用于短网址生成
    php实现斐波那契数列
    五种常见的 PHP 设计模式
    PHP利用MySQL保存session
    HTTP相关
    如何优化tomcat配置(从内存、并发、缓存4个方面)优化
  • 原文地址:https://www.cnblogs.com/allenblogs/p/1810126.html
Copyright © 2011-2022 走看看