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

2024-05-14 00:19:19 发布

您现在位置:Python中文网/ 问答频道 /正文

我知道这个标题看起来很熟悉一些老问题,但我看过每一个,没有一个解决。 这是我的密码:

class Island (object):E,W,R,P
  def __init__(self, x, y):
    self.init_animals(y)
  def init_animals(y):
    pass

isle = Island(x,y)

但是,我得到了以下错误:

Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "<stdin>", line 3, in __init__
TypeError: init_animals() takes 1 positional arguments but 2 were given

如果我有什么错误,请告诉我,我很困惑。 致意


Tags: inself密码标题objectinitdef错误