我正在通过php运行python脚本。它在控制台上工作正常,但在浏览器上运行时返回null。我甚至尝试将输出写入文件,但它不返回任何内容。 PHP代码为:在php中运行脚本
<?php
$y = "python Code.py";
$output = shell_exec($y);
if($output!=null){
echo $output;
}
else {
echo "No output";
}
$myfile = fopen("test.txt", "w") or die("Unable to open file!");
fwrite($myfile, $output);
fclose($myfile);
?>
请问,如果你指定要在'$ y'你的Python脚本的完整路径它的工作? –