-4
我一直在努力的練習中加入的Python:新手Class對象PRAC和__main__
if __name__ == '__main__':
到模塊的末尾測試我的模塊。這個想法是將該模塊作爲腳本運行,並獲得輸出 ,並能夠從其他腳本或交互式Python會話中導入該模塊。
我使用Python 2.6.6
這裏是整個代碼
class Prac:
'''
This module is a practice in creating a main within a module.
'''
def Fun(self):
print "testing function call"
if __name__ == ' __main__':
Fun()
感謝伊格納西奧....咄......忘了實例化對象。將再次嘗試併發布 – wbg
這次是什麼困擾? –
好吧,它看起來像你有工作代碼...你有問題要去嗎? –