【问题标题】:TypeError: 'xxx' takes 1 positional argument but 2 were given [duplicate]TypeError:'xxx'需要1个位置参数,但给出了2个[重复]
【发布时间】:2016-03-20 21:37:38
【问题描述】:

Hier 是我的第一个问题:Name 'xxx' is not defined

编辑后我有这个错误:

self.view_splash(0)
TypeError: view_splash() takes 1 positional argument but 2 were given

我需要做什么来修复它?

【问题讨论】:

  • 我猜你根本不应该传递值
  • 要么不传递参数,要么在方法上定义另一个参数,这取决于您的需要以及您是否拥有所调用的内容。请在此问题中输入minimal reproducible example

标签: python


【解决方案1】:

def view_splash(arg1): 在一个类中,所以你应该使用 staticmethod 装饰器

@staticmethod
def view_splash(arg1):

【讨论】:

  • @staticmethod 在这里不太可能是正确的解决方案。
猜你喜欢
  • 2019-04-15
  • 2017-01-12
  • 2017-04-22
  • 2019-07-07
  • 2020-12-29
  • 2021-09-13
  • 2020-05-05
  • 2021-07-19
  • 2016-11-04
相关资源
最近更新 更多