python 模塊和佈局

寫一個Demo:python

大體7個部分:函數

#1.起始行 code

#2.模塊文檔 文檔

#3.模塊導入io

#4.聲明模塊變量 function

#5.類聲明 class

#6.函數聲明 import

#7.主程序變量

#!/usr/bin python            #1
"Here are module docs"    #2
import sys,os            #3
point = 20            #4

class Demo(object):        #5
    "Demo class docs"
    pass
def other():            #6
    "other function docs"
    demo = Demo()
    if point>10:
        print 'The point is: ',point
other()                #7

---[2012-02-25]---module

相關文章
相關標籤/搜索