最后一行中的“'x.'”错误 "No value for argument 'change' in unbound method call"。 __init__ 方法未使用
error "No value for argument 'change' in unbound method call" for ''x.'' in final line. __init__ method not used
class a:
app = [2,3,5,21,24,28,35]
web = [1,9,22,46]
x = min(app,web);y = max(app,web)
a = len(x)
w = len(y)
c=0;d=0
def till_xbig(self,i ,j ,change):
while self.x[i] < self.y[j] :
self.c+=1
if i<self.a-1 and self.c <self.a:
i+=1
else:
break
change += 1
self.till_ybig(i,j,change)
def till_ybig(self,i,j,change):
while self.y[j] < self.x[i] :
self.d+=1
if j<self.w-1 and self.d<self.w:
j+=1
else:
break
change += 1
if i == self.a-1 and j == self.w-1: return change
self.till_xbig(i,j,change)
x = a
print(x.till_xbig(0,0,0))
**我已将 class 实例分配给 x 但我仍然收到此“方法未绑定调用”错误为什么“self”占用第一个 0 以及更改未收到第三个 0 的原因作为争论。如何避免这样的错误? **
其中 x = a
表示将 x
分配为 a
class.
在你的情况下,应该使用 x = a()
。它将 x
分配为 a
实例。
>>> x = a
>>> x
>>> <class '__main__.a'>
>>> x = a()
>>> x
>>> <__main__.a object at 0x00000215D6FBEF20>
class a:
app = [2,3,5,21,24,28,35]
web = [1,9,22,46]
x = min(app,web);y = max(app,web)
a = len(x)
w = len(y)
c=0;d=0
def till_xbig(self,i ,j ,change):
while self.x[i] < self.y[j] :
self.c+=1
if i<self.a-1 and self.c <self.a:
i+=1
else:
break
change += 1
self.till_ybig(i,j,change)
def till_ybig(self,i,j,change):
while self.y[j] < self.x[i] :
self.d+=1
if j<self.w-1 and self.d<self.w:
j+=1
else:
break
change += 1
if i == self.a-1 and j == self.w-1: return change
self.till_xbig(i,j,change)
x = a
print(x.till_xbig(0,0,0))
**我已将 class 实例分配给 x 但我仍然收到此“方法未绑定调用”错误为什么“self”占用第一个 0 以及更改未收到第三个 0 的原因作为争论。如何避免这样的错误? **
其中 x = a
表示将 x
分配为 a
class.
在你的情况下,应该使用 x = a()
。它将 x
分配为 a
实例。
>>> x = a
>>> x
>>> <class '__main__.a'>
>>> x = a()
>>> x
>>> <__main__.a object at 0x00000215D6FBEF20>