python: NameError:global name '...‘ is not defined

29 浏览
0 Comments

python: NameError:global name '...‘ is not defined

在我的代码中,我有以下内容:

class A:
    def a():
        ......
    def b():
        a()
        ......
    b()

然后编译器会报错“NameError: global name a() is not defined.” 如果我将所有的内容从A类中移出来,就不会有问题,但是我该如何定义A类中的方法呢?非常感谢。

0