-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
这次是什么困扰? –
好吧,它看起来像你有工作代码...你有问题要去吗? –