写了一个demo.py,运行出错,提示 File stdin, line 1

写了一个demo.py,仅有一句,print 'hello world',

运行 Python hello.py 出错,提示:

File "" , 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到demo.py所在目录,运行python demo.py,成功。
 

—— 完 ——
相关推荐
评论

立 为 非 似

中 谁 昨 此

宵 风 夜 星

。 露 , 辰

文章点击榜

细 无 轻 自

如 边 似 在

愁 丝 梦 飞

。 雨 , 花