" , line 1" type="hidden"/>

File " " , line 1


寫了一個hello.py,僅有一句,print 'hello world',

運行 Python hello.py 出錯,提示:

File "<stdin>" , line 1
python hello.py

 

解釋:

In the shell you can run shell commands, in the Python command line you can run Python code.

"python hello.py" is a shell command, not Python code, so you should run it in the shell, but not on the Python command line. 

"print "hello"" is Python code, so you can run it on the Python command line, but not in the shell.

 

故,退出python命令行,直接cd到hello.py所在目錄,運行python hello.py,成功。

 

 

 

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM