Python学习第一个程序:python第一个程序hello.py提示出现File "",line 1错误

 

错误仅含有一句print("hello,world"),但是报错。

原因:


      在shell脚本中,运行shell脚本命令;在Python命令行中,运行Python代码。

      然而,“python hello.py”是一个脚本命令,不是python代码。


      因此,退出python命令行,直接cd到hello.py所在目录,运行python hello.py,即可。


       若是非要在python命令行中运行,输入print("hello world")即可。

发布了24 篇原创文章 · 获赞 10 · 访问量 1万+

猜你喜欢

转载自blog.csdn.net/Y_X_ngu/article/details/81502268