我想知道是否放在python类的顶部的声明是相当于__init__
?例如python类中的声明等价于_init_?
import sys
class bla():
print 'not init'
def __init__(self):
print 'init'
def whatever(self):
print 'whatever'
def main():
b=bla()
b.whatever()
return 0
if __name__ == '__main__':
sys.exit(main())
输出是:
not init
init
whatever
一点题外话,现在我还可以得到:
Fatal Python error: PyImport_GetModuleDict: no module dictionary!
This application has requested the Runtime to terminate it in an unusual way.
Please contact the application's support team for more information.
为什么这是任何想法?先谢谢你!
该错误表明您的Python安装有些问题。这是另一个问题的话题。一定要包括详细信息 - 哪个版本,哪个操作系统,你如何获得它等等。 – delnan 2012-04-28 08:21:58