Python报错:AttributeError
Python报错:AttributeError
这个错误就是说python找不到对应的对象的属性,后来我发现竟然是初始化类的时候函数名写错了:
class Settings():def _init_(self):self.scren_width=1200self.screen_height=800self.bg_color=(230,230,230)
不知道你看出哪错了没,百度了一下才发现__init__是两个下划线,两个下划线,两个下划线:
更改之后的代码:
class Settings():def __init__(self):self.scren_width=1200self.screen_height=800self.bg_color=(230,230,230)
更改之后错误就没有了
其实后来我也发现,当你把init函数写错的时候,它的颜色会提示你的,先来看错误的提示颜色:
再来看更改之后的提示颜色:
所以说,我们在写代码的时候也可以留意一下代码的提示颜色,有时候它会帮助你实时检查代码有没有错误,虽然这么多颜色,我也记不住。。。
在附带上python中常见的几种错误:
Python报错:AttributeError相关推荐
- python报错AttributeError module ‘scipy.misc‘ has no attribute ‘imresize‘和 ‘imread‘
python报错AttributeError: module 'scipy.misc' has no attribute 'imresize'和 'imread' 报错原因:scipy版本过高 解决方 ...
- python 报错 AttributeError: module ‘time‘ has no attribute ‘clock 解决方法
源码如下: #引入所需要的时间库 import datetime import time#程序计时器,启动计时器 start = time.clock()#中间是放置需要测试运行时间的程序代码#计算启 ...
- python 报错 AttributeError: type object ‘datetime.datetime‘ has no attribute ‘datetime‘
python报错:type object 'datetime.datetime' has no attribute 'datetime' 描述:在第一个python程序里还未报错,第二个程序完全复制过 ...
- 第一:Python+Allure运行报错AttributeError: module ‘allure‘ has no attribute ‘severity_level‘
1.很多查询结果都是先卸载pytest-allure-adaptor,然后再安装allure-pytest pip3 uninstall pytest-allure-adaptor 2.pip3 in ...
- python中引入包的时候报错AttributeError: module ‘sys‘ has no attribute ‘setdefaultencoding‘解决方法?
python中引入包的时候报错AttributeError: module 'sys' has no attribute 'setdefaultencoding'解决方法? 参考文章: (1)pyth ...
- 关于在《python编程从入门到实践》书中练习“外星人大战”报错“AttributeError: ‘AlienInvasion‘ object has no attribute ‘blit‘”
关于在<python编程从入门到实践>书中练习"外星人大战"报错"AttributeError: 'AlienInvasion' object has no ...
- pycharm/python报错:Traceback (most recent call last): .....
python报错:Traceback (most recent call last): - python报错: Traceback (most recent call last):File " ...
- pyinstall :打包 .exe 文件报错AttributeError: module ‘enum‘ has no attribute ‘IntFlag‘
有疑问的地方 参考博文 一.环境搭建 Python GUI图形化小工具编程学习-- PySide2 环境搭建(一) 二.实例演示 Python GUI图形化小工具编程学习-- Demo 实例演示(二) ...
- 运行项目时flask_sqlalchemy报错AttributeError: ‘LocalStack‘ object has no attribute ‘__ident_func__‘
运行项目时flask_sqlalchemy报错AttributeError: 'LocalStack' object has no attribute '__ident_func__' 1.原因 2. ...
最新文章
- [JS-JQuery]基础
- 使用PCB Editor 制作元件封装Footprint
- python3练习题:并发编程(21-25)
- 工控随笔_04_西门子_解决Step 7软件因授权问题不能打开的方式和方法
- 关于ngx_trylock_accept_mutex的一些解释
- php mail函数_php 发送邮件函数
- 智能电话机器人中的语音识别技术是什么?
- python机器学习案例系列教程——集成学习(Bagging、Boosting、随机森林RF、AdaBoost、GBDT、xgboost)
- excel mysql乱码_excel打开是乱码的解法方法
- mysql有多少个端口号_mysql默认端口号(mysql端口号是多少)
- [demo] 微信小程序Demo:树芽读书(一个不错的书籍朗读小程序)
- 集成电路和芯片的联系与区别
- Svn内外网切换技巧
- 雅虎 (YAHOO)相册下载工具 Beta1 发布
- python读excel两列为字典_python交换数据的两列,python处理excel数据, python交换...
- 读 Samuel Enoch Stumpf 之《西方哲学史》
- css特效(使用伪元素生成随机颜色爱心)
- python爬虫如何防止IP屏蔽
- VirtualBox Guest Additions
- cmake中添加引用动态链接_CMake 添加头文件目录,链接动态、静态库(添加子文件夹)...
热门文章
- 关于阿里云服务器Linux安装Tomcat后,外网不能访问解决方案
- c#关于int(或其他类型)的字段在对象初始化时默认初始化问题的解决方法
- 【实践】图推荐算法在EE问题上的应用(附交流视频和PPT下载链接)
- git clone失败的问题,网络问题
- 算法工程师,『工程』二字怎么破?
- java jobkey_Java JobBuilder.newJob方法代码示例
- python字符串三,删除空白符,对齐函数及判断函数
- 【封装那些事】 泄露的封装
- 找不到java虚拟机_javabridge.jutil.JVMNotFoundError:找不到Java虚拟机
- php zend mvc 配置,理解Zend Framework 的MVC模式_PHP教程