我想使用self.value的值,这是我在“func1”的函数内部的函数“take”中初始化的。但是,我在尝试这样做时收到了一个错误
代码:
class all():
def __init__(self):
self.temp = self.value # Here I declare it first before the self.new but still get error. May I know why?
if:
**func**
else:
**func**
self.new = self.func1()
def func1(self):
**func**
return ["{}".format(self.temp)]
def take(value):
#In this example, the value already contained some values. and already been called. but in another program not in the same program.
self.value = value
错误:
AttributeError: "all" object has no attribute "value"
出现此错误的原因是,您没有在构造函数(init)方法中定义值
相关问题 更多 >
编程相关推荐