python tutorial 学习笔记(三)
2011-04-01 18:14
393 查看
module –> .py file
import module_name
from module_name import *
module_name.__name__ #returns the module name
module can contain executable statments. They are executed only the first time the module is imported somewhere.
__name__ is “__main__” when the file is executed as main file. Thus statments after “if __name__ == “__main__:” are executed only when the file is main file.
sys module: sys.ps1, sys.path
__builtin__ module: just a name, already built-in
built-in function dir(): which names a module defines
PYTHONPATH(sys.path)
installation-dpendent default
import p1.p2.module
from package import item, item can be a submodule or a function, calss or variable defined in the package
import module_name
from module_name import *
module_name.__name__ #returns the module name
module can contain executable statments. They are executed only the first time the module is imported somewhere.
__name__ is “__main__” when the file is executed as main file. Thus statments after “if __name__ == “__main__:” are executed only when the file is main file.
Standard Modules
Python Libraray Reference.sys module: sys.ps1, sys.path
__builtin__ module: just a name, already built-in
built-in function dir(): which names a module defines
Module Search Path
current directory( the main file directory)PYTHONPATH(sys.path)
installation-dpendent default
Package:
must contain __init__.py file, it can define a list named __all__, containing all module names that should be imported when use “from package import *”import p1.p2.module
from package import item, item can be a submodule or a function, calss or variable defined in the package
相关文章推荐
- Python tutorial: python中文快速学习笔记 - 数字与字符串
- python tutorial 学习笔记(七)Errors and Exceptions
- Python Tutorial 学习笔记1
- Python Tutorial 学习笔记5 --IO
- Python Tutorial 学习笔记6 --Errors and Exceptions
- Python Tutorial 学习笔记3 -- Python Data Structures
- Python Tutorial 学习笔记4 ——Module
- python tutorial 学习笔记(四) Input and Output, 字符串的转换等
- python tutorial 学习笔记(一)
- Python Tutorial 学习笔记2
- Python学习网站(简明python教程,The Python Tutorial,Python学习笔记,啄木鸟社区)
- python tutorial 学习笔记 (五) scope,namespace
- python tutorial 学习笔记(二) Sequence type
- python 学习笔记(9)调试与类继承
- Python学习笔记03 控制流语句和函数
- python学习笔记一 关于python学习前了解的内容
- python学习笔记(基础)
- Python学习笔记(三)
- python学习笔记7.5-内建模块struct
- python基础学习笔记(五)