屏幕上显示的字符串正是自动调用__init__()方法的结果,当一个实例被创建,__init__()就会被自动调用
不管这个__int__()是自定义的还是默认的。
class FooClass(object):
version=0.1
def __init__(self):
print self.version
a=FooClass()
print a
print type(a)
C:UsersAdministratorPycharmProjectsuntitledvenvScriptspython.exe C:/Users/Administrator/PycharmProjects/untitled/a2.py
0.1
<__main__.FooClass object at 0x022AFAB0>
<class '__main__.FooClass'>