iis下php 運行python 指令碼

來源:互聯網
上載者:User

標籤:目錄   指令碼   python版本   head   for   gb2312   cmd命令   iconv   .exe   

一:要注意的問題

1.iis下php要對python有許可權。

2.cmd要所有者許可權。

3.cmd命令列中編碼格式是gbk。

4.exec(),shell_exec(),system(),passthru()的區別。

5.windows版本對應的python版本,我這裡公司系統很老了,遇到很多坑。

二:例子

1.我這裡用的是例子是passthru的例子。也是直接輸出結果。

2.上php源碼

header("Content-type:text/html;charset=utf-8");

// 接收表單(這裡這個params 只是一個例子,主要是讓大家知道怎麼傳參)
$params = $_POST[‘params‘];
$str = iconv("utf-8", "GB2312//IGNORE", $car_card);

// 調用python(這裡目錄都要用完整目錄)
$common = "D:/Python27/python.exe D:/compiled/pingan_data_launch.py $params";
$res = @passthru("$common", $result);

3.上python源碼

# _*_ coding: utf-8 _*_
for i in range(10):
a = ‘我市‘
print(a)

 4.ok了。

iis下php 運行python 指令碼

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.