Python class NameError name "xxx" is not defined

2023-06-14,,

Python class NameError name "xxx" is not defined

这是因为在 class 中调用了带双下划线 "__" 的函数对象,例如:

def __fun():

  pass

class A():

  def __init__(self):

    __fun()  #会报错,不要调用外部带 __ 的函数

Python class NameError name "xxx" is not defined的相关教程结束。

《Python class NameError name "xxx" is not defined.doc》

下载本文的Word格式文档,以方便收藏与打印。