duanao2688 2014-02-18 05:34
浏览 72
已采纳

PHP和Python集成:从PHP页面调用python脚本并回复它[重复]

This question already has an answer here:

I have some scripts written in Python which upload files reads database and modify uploaded files. I want to make a web portal for doing the same work.

It is possible to call this Python script from the PHP code?

I found and here and also here but how to pass parameter in it? How will I pass uploaded file to it? or is it okay to leave that code into python script?

Python script generate interactive bulk result. How to revert back with that on PHP page?

I have tried to find answers and I've found many but I don't know the best way to do it.

Can someone please give me the best scenario to design this system?

EDIT : Problem Scenario

  • I to ask user to upload a file.
  • I'll query database on the basis of the info in that file.
  • File can have hundreds of units for which I have to query database and prompt user to choose related units.
  • Complete process is interactive up-to the numbers of units in the file.
  • On the basis of user selection I've modify the uploaded file and give it back to the user.
</div>
  • 写回答

1条回答 默认 最新

  • dongliu6848 2014-02-18 05:43
    关注

    There are many ways to solve this problem, just a few off the top of my head:

    1. Create a queue, where your PHP script deposits work items that your Python script reads, performs the work, and then updates a status table.

    2. Create an API for your Python script which your PHP script (or any other script) can consume.

    3. Dump your input into a directory which the Python script watches for data, and then writes the result to the file system where you can read and display it using PHP.

    There are more scenarios you can use but as you haven't provided any information about the system it is difficult to recommend a solution. For example, do you need intermittent updates on the status of the work being done? Is the job something that can be queued or will you block your PHP application? Are the two scripts on the same system or are they distributed? How are you communicating between the two scripts?

    The "best" can only be provided if you give us your system constraints.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 孟德尔随机化怎样画共定位分析图
  • ¥18 模拟电路问题解答有偿速度
  • ¥15 CST仿真别人的模型结果仿真结果S参数完全不对
  • ¥15 误删注册表文件致win10无法开启
  • ¥15 请问在阿里云服务器中怎么利用数据库制作网站
  • ¥60 ESP32怎么烧录自启动程序
  • ¥50 html2canvas超出滚动条不显示
  • ¥15 java业务性能问题求解(sql,业务设计相关)
  • ¥15 52810 尾椎c三个a 写蓝牙地址
  • ¥15 elmos524.33 eeprom的读写问题