当前位置: 代码迷 >> 综合 >> Python报错集合篇10-NameError: name 'namee' is not defined
  详细解决方案

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

热度:51   发布时间:2024-01-24 15:38:35.0

本文介绍如何处理报错–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"
JackProcess finished with exit code 0
  相关解决方案