-2
PHP代碼:嘿,我有這樣的PHP代碼來調用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)
它仍然給錯誤:Array([0] => C:/ Python27/python:無法打開文件'c:/scripts/qwer.py':[Errno 2]沒有這樣的文件或目錄) – abcdxx
@abcdxx'c:/ scripts/qwer.py'只是一個例子,根據你的系統使用'qwer.py'文件的完整路徑。 –
我寫道:exec(「C:/ Python27/python C:/xampp/htdocs/qwer.py 2>&1」,$ output); print_r($ output);但它並沒有創建任何myfile.txt,儘管現在沒有給出任何錯誤 – abcdxx