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 "<pyshell#7>", line 1, in <module>

    d = Athlete("Holy Grail")

  File "<pyshell#6>", line 3, in __init__

扫描二维码关注公众号,回复: 305406 查看本文章

    self.thing = vlaue

NameError: name 'vlaue' is not defined

 

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

猜你喜欢

转载自zhangshufei8001.iteye.com/blog/2393812