admin管理员组

文章数量:1642181

在运行Python程序的时候,系统如果报下面这种错误:

Traceback (most recent call last):
  File "/Users/yushengtan/PycharmProjects/Demo//trafficlightdemo01.py", line 37, in <module>
    if light01.light[row][col] == False:
AttributeError: 'Light' object has no attribute 'light'

AttributeError: ‘自定义类’ object has no attribute ‘自定义属性’;
意思是系统获取不到你自定义的这个类的某个属性,如果Python程序运行报这种类型的错误,大多情况下是由于__init__这个构造方法函数名,写得不正确。下划线少些了一个或者init拼错了~

本文标签: 解决办法程序PythonAttributeError