无法使用shell_exec在本地服务器上的php上执行python文件

时间:2019-05-20 05:31:39

标签: php python-3.x xampp shell-exec

im试图在php上执行.py文件。我已经通过anaconda 3.7安装了我的python

ive尝试使用shell_exec命令,但它不执行.py文件的输出。只需打开.py文件即可。

#the output should be test
print ("test")

.py文件保存了test.py

<?php
$command = escapeshellcmd('test.py');
$output = shell_exec($command);
echo $output;
?>

.php文件另存为cb.php

我将它们放在htdoc中名为test的相同文件中。我键入http://localhost/test/cb.php在浏览器上运行php文件。我希望应该执行.py代码,并且php文件应该输出“ test”,但是test.py文件只是在崇高的文本(我的默认文本编辑器)上打开的。

0 个答案:

没有答案