简体   繁体   English

如何在 web 服务器上的 php 脚本上运行 python 文件?

[英]How to run an python file on php script on web server?

I am trying to host a website running on php calling a python script on web server.我正在尝试托管在 php 上运行的网站,该网站在 web 服务器上调用 python 脚本。

The web server name (Host) is heroku.com whenever I try to execute my python script with php it does not work (execute). The web server name (Host) is heroku.com whenever I try to execute my python script with php it does not work (execute).

I think the code itself is little much wrong.我认为代码本身几乎没有错误。

below is the php code for calling python file - forphp.py下面是调用 python 文件的 php 代码 - forphp.py

$command = escapeshellcmd('forphp.py');
$py = shell_exec($command);

you almost have it你几乎拥有它

$cmd = "python forphp.py"
shell_exec($cmd);

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM