[英]Getting Traceback (most recent call last): File "<stdin>", line 1, in <module> NameError: name 'filename' is not defined
When running a script containing this code:运行包含此代码的脚本时:
print('Hello world')
I get this error message:我收到此错误消息:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
NameError: name 'filename' is not defined
I have double checked that I am in the current working folder ( os.getcwd()
).我已经仔细检查了我是否在当前的工作文件夹中( os.getcwd()
)。
What could be wrong?有什么问题?
I think it's better to use Command Prompt to run python file.我认为最好使用命令提示符来运行 python 文件。
Go to your current directory that contains python file and open Command Prompt.转到包含 python 文件的当前目录并打开命令提示符。 Run your python file as "python filename.py".将您的 python 文件作为“python filename.py”运行。
That will be good.那会很好。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.