Python 属性错误:';分词法';对象没有属性';制作动画';

Python 属性错误:';分词法';对象没有属性';制作动画';,python,python-3.x,Python,Python 3.x,我已经用Python编写了一段时间的脚本,但现在我正在深入研究类和OOP 我得到以下错误: Traceback (most recent call last): File "practice.py", line 10, in <module> l.animate(2,"L...R.L..") AttributeError: 'particleAnimation' object has no attribute 'animate' 我正在运行Python 3.6.

我已经用Python编写了一段时间的脚本,但现在我正在深入研究类和OOP

我得到以下错误:

Traceback (most recent call last):
  File "practice.py", line 10, in <module>
    l.animate(2,"L...R.L..")
    AttributeError: 'particleAnimation' object has no attribute 'animate'

我正在运行Python 3.6.3。为什么会出现这种异常?

不要忘记缩进在Python中很重要

在当前缩进中,
animate
属于
\uuuuu init\uuuu
而不是
particleAnimation

以下是您应该拥有的内容,请注意
\uuuu init\uuuu
animate
具有相同的缩进级别

class particleAnimation(object):
    def __init__(self):
        ...

    def animate(self, speed, init):
        ...
class particleAnimation(object):
    def __init__(self):
        ...

    def animate(self, speed, init):
        ...