在使用python自定义类时,定义了一个类,但是在调用时,发生了如下错误:
>>> class Athlete:
def __init__(self, value=0):
self.thing = vlaue
def how_big(self):
return(len(self.thing))
>>> d = Athlete("Holy Grail")
Traceback (most recent call last):
File "
d = Athlete("Holy Grail")
File "
self.thing = vlaue
NameError: name 'vlaue' is not defined
经过仔细检查发现, vlaue写错了,改为value就没有问题了,一定要仔细啊!