__init__ 实例化对象,__init__并不相当于C#中的构造函数,执行它的时候,实例已构造出来了。
class Node:
def __init__(self, value):
self._value = value
self._children = []
# Example
if __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'>
python __init__ 实例化对象
转载本文章为转载内容,我们尊重原作者对文章享有的著作权。如有内容错误或侵权问题,欢迎原作者联系我们进行内容更正或删除文章。
上一篇:python 装饰器
下一篇:python 迭代器
提问和评论都可以,用心的回复会被更多人看到
评论
发布评论
相关文章
-
init()命令 python python __init__()
python中安装目录中的Lib文件夹模块中的__init__.py文件(文件内容可以为空),用于标识此文件夹是一个模块python编程中的__init__表示初始化
init()命令 python python python编程 初始化