python __init__ 实例化对象

来源:互联网 发布:反演变换知乎 编辑:程序博客网 时间:2024/06/03 18:18
__init__  实例化对象,__init__并不相当于C#中的构造函数,执行它的时候,实例已构造出来了。class Node: def __init__(self, value):    self._value = value    self._children = []# Exampleif __name__ == '__main__':  root = Node(0)  print root  print type(root)C:\Python27\python.exe C:/Users/TLCB/PycharmProjects/untitled/mycompany/Django/a31.py<__main__.Node instance at 0x01C5BDF0><type 'instance'>

原创粉丝点击