shell脚本命令 运行python文件&python命令行运行python代码

单独的python文件运行的时候 报错:

shell脚本命令 运行python文件&python命令行运行python代码_第1张图片

在shell脚本中,运行shell脚本命令;在Python命令行中,运行Python代码。然而,“python hello.py”是一个脚本命令,不是python代码。

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

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

 

总结:

shell脚本命令 里直接运行python文件

python命令行 运行单独的python代码

转载于:https://www.cnblogs.com/Jordandan/p/7059038.html

你可能感兴趣的:(shell脚本命令 运行python文件&python命令行运行python代码)