如何在php中运行exe文件

2024-04-18 07:04:34 发布

您现在位置:Python中文网/ 问答频道 /正文

我正在研究python中的分类算法,它与php代码相关,为了得到正确的结果,我应该运行python exe,然后转到php代码。在

我想用php代码单独执行python。我试过了:

<?php
// outputs the username that owns the running php/httpd process
// (on a system with the "whoami" executable in the path)
echo exec('whoami');
?>

但它不起作用,我应该知道更多关于路径的信息吗?以及如何将exe放入写入路径?在


Tags: the代码路径算法thatusername分类outputs
1条回答
网友
1楼 · 发布于 2024-04-18 07:04:34
<?php
exec("C:\\Users\\posh\\AppData\\Local\\Programs\\Python\\Python35\\python.exe YOUR_PYTHONSCRIPT.py <arguments if any>", $output, $ret_code);
// directly writing python may not work in that case 
// give path to python.exe
exec("python YOUR_PYTHONSCRIPT.py <arguments if any>", $output, $ret_code);
// $ret_code : returns the code 0 or 1
// output is an array
?>

相关问题 更多 >