錯誤提示:
在命令行輸入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