嘿,我有这个php代码来调用python文件,但是当我在浏览器上运行php代码时,它给出了一个错误..:

嘿,我有这个php代码来调用python文件,但是当我在浏览器上运行php代码时,它给出了一个错误..:,php,python,Php,Python,php代码: <?php exec("C:/Python27/python qwer.py 2>&1", $output); print_r($output); ?> 错误: Array ( [0] => C:/Python27/python: can't open file 'qwer.py': [Errno 2] No such file or directory ) 给出qwer.py的完整路径,如下所示 <?php exec("

php代码:

<?php
   exec("C:/Python27/python qwer.py 2>&1", $output);
   print_r($output);
?>
错误:

Array ( [0] => C:/Python27/python: can't open file 'qwer.py': [Errno 2] No such file or directory )

给出qwer.py的完整路径,如下所示

<?php
   exec("C:/Python27/python c:/scripts/qwer.py 2>&1", $output);
   print_r($output);
?>


它仍然给出错误:Array([0]=>C:/Python27/python:无法打开文件'C:/scripts/qwer.py':[Errno 2]没有这样的文件或目录)@abcdxx
C:/scripts/qwer.py
只是一个示例,根据您的系统使用文件
qwer.py
的完整路径。我写道:exec(“C:/Python27/python C:/xampp/htdocs/qwer.py 2>”&1”(单位:百万元),;打印(输出);但是它仍然没有创建任何myfile.txt,尽管没有给出任何错误now@AshwiniChaudhary它仍然没有创建任何myfile.txt,尽管它没有给出任何错误now@abcdxx它必须正在创建“myfile.txt”,请查看正确的位置。但是文件将是空的,因为您没有将数据从缓冲区刷新到文件。在
f.write
行之后添加
f.close()。
<?php
   exec("C:/Python27/python c:/scripts/qwer.py 2>&1", $output);
   print_r($output);
?>