且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

通过使用PHP exec()运行Python脚本

更新时间:2022-04-06 04:27:14

即使您的python脚本也可能有几个问题.

There can be several problems with even your python script.

首先:您可以从控制台运行此脚本吗? (脚本的开头是否有#!/path/to/env/python)? 如果不是,则将其添加到脚本或exec函数中(不带#!)

First: Can you run this script from console? (Do you have a #!/path/to/env/python in the script's beginning)? If not, then either add it to your script or to the exec function (without #!)

您还可以使用passthru代替exec,以便显示脚本的原始输出.

You can also use passthru instead of exec, so you can display the raw output of the script.