【问题标题】:Takes 1 argument, but 2 were given接受 1 个参数,但给出了 2 个参数
【发布时间】:2017-12-29 04:31:10
【问题描述】:

update() 接受 1 个位置参数,但给出了 2 个

如何解决这个错误?

all_sprites.update(dt)

它只有 1 个参数,但说我有 2 个?

【问题讨论】:

  • self 是一个隐式参数。删除dt

标签: python pygame


【解决方案1】:

您的精灵的update 方法已经有self 作为参数。如果你想向它传递额外的值,你必须将它们添加到函数定义中。例如:

    def update(self, dt):

【讨论】:

    猜你喜欢
    • 2016-10-13
    • 2019-04-20
    • 2018-11-15
    • 2014-07-19
    • 2016-08-09
    • 2020-01-30
    • 2019-08-02
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多