【问题标题】:What does the number following the argument represent?参数后面的数字代表什么?
【发布时间】:2019-10-12 03:13:59
【问题描述】:

我想知道参数后面的数字代表什么(在错误消息中;数字是 1)。

我正在更新 PsychoPy,它显示了错误消息。找了一阵子,没找到任何解释。

def onCancel(self, event):
    self.app.updater = None
    self.Close()

def onFileBrowse(self, event):
    self.filename = event.GetString()

def onInstall(self, event):
    if self.currentSelection == self.useLatestBtn:
        info = self.doAutoInstall()
    else:
        info = self.installZipFile(self.filename)
    self.statusMessage.SetLabel(info)
    self.Fit()

Traceback (most recent call last):
  File "C:\Program Files (x86)\PsychoPy3\lib\site- 
packages\psychopy\app\connections\updates.py", line 404, in onInstall
    self.statusMessage.SetLabel(info)
TypeError: Control.SetLabel(): argument 1 has unexpected type 'int'

【问题讨论】:

  • 错误是说info 是int 类型。您的 self.statusMessage.SetLabel() 似乎不接受 int。
  • 数字只是指定它所指的函数参数。如果一个函数调用有三个参数,并且它想要引用第二个参数,它会说“参数 2”。
  • 使用@ 和@TomKarzes 之类的名字,向您发表评论的人发送通知。你在这里有什么疑问?你的错误在于这个self.statusMessage.SetLabel() 方法。这在您的问题中不存在。
  • 谢谢你们。在提问部分,我想知道参数后面的数字的表示。我也对这个错误感到困惑,但我认为这个问题是在 PsychoPy 上指定的,我会在 PsychoPy 论坛中提问。

标签: python arguments typeerror


【解决方案1】:

正如@TomKarzes 在 cmets 中指出的那样,这只是简单的英语:argument 1 指的是第一个参数。 argument 2 将引用第二个参数,依此类推。

【讨论】:

    猜你喜欢
    • 2021-05-08
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多