python中name 'self' is not defined?

代码如下:报错为name 'self' is not defined,请问是什么原因?

class ListNode(object):
    def __init__(self, x):
        self.val = x
        self.next = None
查看回复