本文介绍如何处理报错–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