模块的结构和布局

#/usr/bin/env puthon      (1)起始行(只有咋UNIX环境下使用,用来直接通过文件名来执行文件)

“”“this is a test module”     (2)模块文档(文档字符串)

import sys 

import os                             (3)模块导入

debug=Ture                       (4)全局变量

class Fooclass (object):

  "Foo class"

  pass        (5)类定义

def test():

  "test function"

        foo=FooClass()

  if debug:

    print 'ran test'    (6)定义函数

if   _name_=='_main_':

test()            (7)主程序

原文地址:https://www.cnblogs.com/nku-wangfeng/p/7686093.html