NameError: name 'vlaue' is not defined

阅读更多

在使用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 "", line 1, in

    d = Athlete("Holy Grail")

  File "", line 3, in __init__

    self.thing = vlaue

NameError: name 'vlaue' is not defined

 

经过仔细检查发现, vlaue写错了,改为value就没有问题了,一定要仔细啊!

你可能感兴趣的:(python,自定义类,NameError)