[質問]これはなぜですか?

1497 ワード

コード:
#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_パラメータは入ってはいけませんか?