Python “列表”对象没有“更新”属性

Python “列表”对象没有“更新”属性,python,list,updates,scite,Python,List,Updates,Scite,我是一名新成员,也是一名使用Python的SciTE的新手程序员。我有一个项目,在这个项目中,我必须制作一个游戏,让一个动画人物做跳跃动作,我正在尝试运行它,只是为了显示我的列表对象在引擎函数中没有“更新”。我有一段很长的代码。我在想问题出在哪里 计时器类别: def __init__(self,position,start_value,size = 20,color = gc.WHITE,font = "Arial"): ''' Initializes the timer.

我是一名新成员,也是一名使用Python的SciTE的新手程序员。我有一个项目,在这个项目中,我必须制作一个游戏,让一个动画人物做跳跃动作,我正在尝试运行它,只是为了显示我的列表对象在引擎函数中没有“更新”。我有一段很长的代码。我在想问题出在哪里

计时器类别:

def __init__(self,position,start_value,size = 20,color = gc.WHITE,font = "Arial"):
    ''' Initializes the timer.
        Start value is in seconds. '''
    self.original_time = start_value    

    self.time = start_value

    self.max = start_value * 1000

    self.x = position[0]
    self.y = position[1]

    self.size = size
    self.color = color
    self.font = font

    self.active = False

    pass

def is_active(self):
    """ Tells the program if the timer is on. """

    return self.active

def get_value(self):
    """ Tells the program the current value of the timer. """
    return self.time

def start(self,time = None):
    """ Starts the timer. """
    self.active = False
    self.time = self.original_time

    pass

def update(self,time):
    """ Iterates the value of the timer.
        deactivate returns True if the timer reaches zero. """

    deactivate = False
    if self.active:
        #
        # Iterate time
        #

        self.time -= time

        #
        # Deactivate the timer when the countdown finishes.
        #
        if self.time <= 0:
            self.stop()
            dreactivate = True


    return deactivate

def draw(self,screen):
    """ Prints the value of the timer to the screen. """

    output = format_time(self.time)
    position = [self.x, self.y]

    #
    # Print the output string
    #
    gc.screenprint(screen,outpit,position)
回溯:

Traceback (most recent call last):
  File "jumpingjacks_template(1).py", line 458, in <module>
    main()
  File "jumpingjacks_template(1).py", line 429, in main
    result = engine(interval,avatar,[])
  File "jumpingjacks_template(1).py", line 316, in engine
    timer.update(interval)
AttributeError: 'list' object has no attribute 'update'
然后函数代码调用timer.update,该函数相当于[].update,因此它会抛出AttributeError


您需要查看第429行,找出为什么在第三个参数中使用列表。

首先,修复缩进。您是从哪里得到这个错误的?请把整个回溯,只显示相关部分
Traceback (most recent call last):
  File "jumpingjacks_template(1).py", line 458, in <module>
    main()
  File "jumpingjacks_template(1).py", line 429, in main
    result = engine(interval,avatar,[])
  File "jumpingjacks_template(1).py", line 316, in engine
    timer.update(interval)
AttributeError: 'list' object has no attribute 'update'
Traceback (most recent call last):
  File "jumpingjacks_template(1).py", line 458, in <module>
    main()
  File "jumpingjacks_template(1).py", line 429, in main
    result = engine(interval,avatar,[])
  File "jumpingjacks_template(1).py", line 316, in engine
    timer.update(interval)
AttributeError: 'list' object has no attribute 'update'