Python-基础

缩进相同的一组语句构成一个代码块,称之为代码组:代码组首行以关键字开始,以冒号“:”结束,该行之后的一行或多行构成代码组!

 

模块结构和布局:这里有一个__doc__文档属性,可以访问模块,或者函数的说明文档

1、起始行

2、模块文档

3、模块导入

4、变量定义

5、类定义

6、函数定义

7、主程序

#/usr/bin/env python    #1、Startup line

"this is a test module"  #2、Module documentation

import sys                     #3、Import Modules
import os

debug = True                #4、global variables declarations

class FooClass():           #5、class declarations
    "Foo Class Documentation"
    pass

def test():                       #6、functions declarations 
    foo = FooClass()
    if debug:
        print 'ran test()'

if __name__ == "__main__":    #7、main __name__属性指示模块应该如何被加载!
    test()

  

 

posted @ 2014-04-30 11:43  doublehappyi  阅读(151)  评论(0编辑  收藏  举报