[英]Run python script from PHP in windows
I want to run python
script from php
. 我想从
php
运行python
脚本。 I am on python 3.5 , 64 bit
.I have read StackQ1 and StackQ2 . 我在
python 3.5 , 64 bit
3.5,64 python 3.5 , 64 bit
。我已经阅读了StackQ1和StackQ2 。 No one was helpful. 没有人提供帮助。 I am running this code
我正在运行这段代码
<?php
$py = exec("D:/pythonFolder/python C:/wamp64/www/python.py");
echo $py;
?>
D:/pythonFolder/python
is the path to python.exe
. D:/pythonFolder/python
是python.exe
的路径。 On running the above code, nothing happens. 运行上面的代码后,什么都没有发生。 I also tried with this
$py = shell_exec("python C:/wamp64/www/python.py");
我也尝试过使用
$py = shell_exec("python C:/wamp64/www/python.py");
and this $py = exec("python C:/wamp64/www/python.py");
和这个
$py = exec("python C:/wamp64/www/python.py");
but no success. 但没有成功。 Any help will be appreciative.
任何帮助将是感激的。
If you want to capture any output from the python script, you need to use shell_exec. 如果要捕获python脚本的任何输出,则需要使用shell_exec。 Otherwise you're just running the script and the output isn't going anywhere.
否则,您只是在运行脚本,并且输出不会流到任何地方。 There are different commands for different purposes.
有不同目的的不同命令。 Exec only runs a command, doesn't care about any potential return values.
Exec仅运行命令,不关心任何潜在的返回值。
http://php.net/manual/en/book.exec.php http://php.net/manual/zh/book.exec.php
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.