• 技术文章 >Python技术 >Python基础教程

    python中AttributeError异常的介绍

    小妮浅浅小妮浅浅2021-10-15 15:45:56原创26007

    1、当你访问一个对象的属性,但是这个属性没有被这个对象定义时,导致AttributeError。

    2、AttributeError的错误信息行告诉我们特定对象类型没有访问属性。点击文件链接可以快速定位到具体的错误代码的位置。

    实例

    a_list  = (1, 2)
    a_list.append (3)
    运行之后抛出异常信息
    Traceback  (most  recent  call  last ):
      File  "/Users/chenxiangan/pythonproject/demo/exmpale.py", line  2, in  <module>
        a_list.append (3)
    AttributeError: 'tuple' object  has  no  attribute  'append'

    以上就是python中AttributeError异常的介绍,希望对大家有所帮助。更多Python学习指路:python基础教程

    专题推荐:python attributeerror
    品易云
    上一篇:python闭包的特点 下一篇:python列表访问的方法

    相关文章推荐

    • python函数定义的规则• python匿名函数的命名规则• python中rindex函数是什么• python中TKinter组件的使用• python TKinter的消息传递机制• python中TKinter的绑定方法• python TKinter普通菜单的介绍• python TKinter弹出式菜单的使用• python canvas画布的介绍• python中sys.argv模块的介绍• python中getopt模块是什么• python中argparse库是什么• python如何委派生成器• python闭包的特点

    全部评论我要评论

    © 2021 Python学习网 苏ICP备2021003149号-1

  • 取消发布评论
  • 

    Python学习网