此文章是vip文章,如何查看?  

1,点击链接获取密钥 http://nicethemes.cn/product/view29882.html

2,在下方输入文章查看密钥即可立即查看当前vip文章


Python报错集合篇10-NameError: name 'namee' is not defined

  • 时间:
  • 浏览:
  • 来源:互联网

本文介绍如何处理报错–NameError: name ‘namee’ is not defined

源代码:


name = "Jack"

print(namee)

运行报错如下:

Traceback (most recent call last):
  File "D:/Program Files/PycharmProjects/pycharmPrj/zzz/lx/lx2.py", line 2, in <module>
    print(namee)
NameError: name 'namee' is not defined

由上报错“name ‘namee’ is not defined”,可知道python告诉我们“namee”这个变量未被定义;一般也就是有两种情况会出现这个报错;一是未给变量赋值,二是变量名输错。由此可判断上面代码是变量名称写错了。只需修改变量名称为“name”就行,代码修改如下:


name = "Jack"

print(name)

运行结果如下:

C:\Python37\python.exe "D:/Program Files/PycharmProjects/pycharmPrj/zzz/lx/lx2.py"
Jack

Process finished with exit code 0

本文链接http://element-ui.cn/news/show-18003.aspx