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

2024-09-27 04:26:22 发布

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

php代码:

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

Python代码:

f = open('myfile.txt','w')
f.write('hi there\n')

错误:

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

Tags: 代码pytxtoutputopenhimyfilefile
1条回答
网友
1楼 · 发布于 2024-09-27 04:26:22

给出完整的路径qwer.py公司就像下面一样

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

相关问题 更多 >

    热门问题