文章详情

  • 游戏榜单
  • 软件榜单
关闭导航
热搜榜
热门下载
热门标签
php爱好者> php文档>Python - Importing Modules

Python - Importing Modules

时间:2010-08-27  来源:AllenW

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.

相关阅读 更多 +
排行榜 更多 +
清道夫模拟器无限金币

清道夫模拟器无限金币

休闲益智 下载
魔法工艺免费完整版

魔法工艺免费完整版

休闲益智 下载
画个腿快跑(内置菜单)2026最新版本

画个腿快跑(内置菜单)2026最新版本

休闲益智 下载