|
马上注册,结交更多好友,享用更多功能^_^
您需要 登录 才可以下载或查看,没有账号?立即注册
x
class Task:
def __init__(self):
self.image_window_list = []
def setImageWindowList(a,b):
if (a > b):
print(1)
def getImageWindowList(c,d):
return Task.setImageWindowList(c,d)
e = Task()
print(e.getImageWindowList(2,1))
求助大佬,为啥会报TypeError: getImageWindowList() takes 2 positional arguments but 3 were given这个错误?怎样改正可以使得e.getImageWindowList(2,1)的输出结果为1呢?
因为实例调用实例方法会将实例本身传递进去,所以得加个 self 形参来接收实例本身
class Task:
def __init__(self):
self.image_window_list = []
def setImageWindowList(self, a,b):
if a > b:
return 1
def getImageWindowList(self, c,d):
return self.setImageWindowList(c,d)
e = Task()
print(e.getImageWindowList(2,1))
|
|