在命令行输入python py文件名称,提示:python: can’t open file ‘hello’: [Errno 2] No such file or directory
D:\juzicode>python hello
python: can't open file 'hello': [Errno 2] No such file or directory
1、本意是要用python运行hello.py文件,少写了后缀,所以提示不能打开hello文件:
2、如果输入python hello.py 仍提示一样的内容,需要确认下hello.py是否在当前目录下,下图所示的当前目录是指D:\juzicode。
1、如果少写了.py后缀,输入完整的文件名称:python hello.py
2、查找hello.py文件的目录,在cmd命令行切换到py文件的目录下再运行python hello.py