首页 > 其他 > 详细

[提问] 这是为什么呢?

时间:2015-07-25 18:02:03      阅读:189      评论:0      收藏:0      [点我收藏+]

代码:

#BSF search
class TreeNode:
    def _init_(self,x):
        self.val = x
        self.left = None
        self.right = None
        
    def kthSmallest(self, root, k):
        print x

 

结果:

>>> a = TreeNode(2)

Traceback (most recent call last):
  File "<pyshell#142>", line 1, in <module>
    a = TreeNode(2)
TypeError: this constructor takes no arguments
>>> a = TreeNode()
>>> a
<__main__.TreeNode instance at 0x0000000002AC44C8>
>>> 

难道是因为def _init_里面不能有参数?

[提问] 这是为什么呢?

原文:http://www.cnblogs.com/wnan42/p/4676175.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!