首页
学习
活动
专区
工具
TVP
发布
精选内容/技术社群/优惠产品,尽在小程序
立即前往

复制错误: AttributeError:' CustomClass‘对象没有属性’CustomClass‘

复制错误: AttributeError:'CustomClass'对象没有属性'CustomClass'

这个错误是由于在代码中尝试访问一个不存在的属性或方法导致的。在这种情况下,'CustomClass'对象没有名为'CustomClass'的属性。

要解决这个错误,需要检查代码中的拼写错误或逻辑错误。确保正确地引用了对象的属性或方法。

如果你需要更具体的帮助,请提供更多的代码细节,以便我能够更准确地帮助你解决问题。

页面内容是否对你有帮助?
有帮助
没帮助

相关·内容

  • python『学习之路03』面向对象

    #!/usr/bin/env python # -*- coding: utf-8 -*- # @Time : 2017/11/21 18:48 # @Author : mixiu26 class Role(object): n=123 # 类变量 def __init__(self,name,role,weapon,life_value = 100,money = 15000): # 类执行前先执行__init()__方法 # __init__() ----- >> 数据初始化:用于数据初始化赋值 self --- >> 相当于java中的this . this.name = name的意思,谁调用构造,self就相当于是谁 # ----- >> 构造函数 # ----- >> 在创建对象时完成数据初始化. self.name = name # ---- >> 成员变量 ---- >> 静态属性 self.role = role self.weapon = weapon # self.life_value = life_value self.__life_value = life_value # 将成员变量设置为私有属性,对外提供公共访问方法,在变量前加上双下划线即可 self.money = money def shot(self): # ----- >> 类的方法 ---- >> 动态属性 print("shotting..........") def __got_shot(self): # 成员方法私有,对外提供公共访问方法function() # 在本类中可修改私有成员属性值 self.__life_value -= 20 print("%s 被打中了....." %self.name) def buy_gun(self,gun_name): print("%s just bought %s" %(self.name, gun_name)) # 对外提供公共访问方法 def show(self): print("%s生命值仅剩: %s" % (self.name,self.__life_value)) def function(self): self.__got_shot() # 析构函数 ---- >> 在实例释放,准备销毁时候执行,通常用于一些收尾处理,关闭内存空间,关闭数据库连接,关闭打开的临时文件 # 格式: def __del__(self): # def __del__(self): # 实例释放时自动执行,不接收任何参数: # print("%s 实例释放: " % self.name) r1 = Role('mixiu26','police','AK46') # 创建角色 ---- >> 实例化 ---- >> 初始化类 ---- >> 创建对象 # # 实例化: ---- >> 把一个类变成一个具体对象的过程,称为实例化 r2 = Role('hzh31','terrorlist','B22') # ---- >> 实例变量,作用域是实例本身 --- >>Role的实例 # r1.buy_gun('AK46') # r2.buy_gun('B22') # r1.got_shot() AttributeError: 'Role' object has no attribute 'got_shot' # r2.got_shot() AttributeError: 'Role' object has no attribute 'got_shot' r1.function() r2.function() r1.show() r2.show() # print(r1.self.__life_value) AttributeError: 'Role' object has no attribute 'self' # ---- >> 其实就相当于在栈中申请了空间,其实相当于在__iniy()__方法中申请了空间 r2, 然后Role(),其实就是相当与在堆内存开辟了一个空间 # ---- >> Role就相当于对数据进行初始化,name = null ,role = null,weapon = null, 其实还有方法区的初始化,然后Role中的方法区就有一个内存地址 # ---- >> Role()时就

    03

    Python 标准异常总结

    以下是 Python 内置异常类的层次结构: BaseException +-- SystemExit +-- KeyboardInterrupt +-- GeneratorExit +-- Exception       +-- StopIteration       +-- ArithmeticError       |    +-- FloatingPointError       |    +-- OverflowError       |    +-- ZeroDivisionError       +-- AssertionError       +-- AttributeError       +-- BufferError       +-- EOFError       +-- ImportError       +-- LookupError       |    +-- IndexError       |    +-- KeyError       +-- MemoryError       +-- NameError       |    +-- UnboundLocalError       +-- OSError       |    +-- BlockingIOError       |    +-- ChildProcessError       |    +-- ConnectionError       |    |    +-- BrokenPipeError       |    |    +-- ConnectionAbortedError       |    |    +-- ConnectionRefusedError       |    |    +-- ConnectionResetError       |    +-- FileExistsError       |    +-- FileNotFoundError       |    +-- InterruptedError       |    +-- IsADirectoryError       |    +-- NotADirectoryError       |    +-- PermissionError       |    +-- ProcessLookupError       |    +-- TimeoutError       +-- ReferenceError       +-- RuntimeError       |    +-- NotImplementedError       +-- SyntaxError       |    +-- IndentationError       |         +-- TabError       +-- SystemError       +-- TypeError       +-- ValueError       |    +-- UnicodeError       |         +-- UnicodeDecodeError       |         +-- UnicodeEncodeError       |         +-- UnicodeTranslateError       +-- Warning            +-- DeprecationWarning            +-- PendingDeprecationWarning            +-- RuntimeWarning            +-- SyntaxWarning            +-- UserWarning            +-- FutureWarning            +-- ImportWarning            +-- UnicodeWarning            +-- BytesWarning            +-- ResourceWarning

    02
    领券