[英]Communication of my Python program with php
I have written a python which used to take values from command line and process the same. 我写了一个python,它从命令行获取值并进行处理。 5 variables are taken using raw_input() and in each case something is returned to screen.
使用raw_input()获取5个变量,并且每种情况下都会返回到屏幕。
I want this whole interaction to happen via php program which calls my python program. 我希望整个交互通过调用我的python程序的php程序进行。 They are supposed to exchange variables more than one time.
他们应该多次交换变量。
I have read the possible solutions like running the python through php via shell and passing arguments. 我已经阅读了可能的解决方案,例如通过shell和传递参数通过php运行python。 But I am not sure how once I start my python program I can simply keep on sending variables to it so that my python program reaches its logical end by getting variables from php.
但是我不确定一旦启动我的python程序,我如何可以继续向它发送变量,以便我的python程序通过从php获取变量来达到其逻辑终点。
you have to use an IPC mechanism like file, pipe, named pipe, shared memory,... http://en.wikipedia.org/wiki/Inter-process_communication 您必须使用IPC机制,例如文件,管道,命名管道,共享内存等... http://en.wikipedia.org/wiki/Inter-process_communication
You can generally communicate between languages by using common language formats, and using
stdin
andstdout
[pipe] to communicate the data.通常,您可以通过使用通用语言格式以及使用
stdin
和stdout
[pipe]来传递数据来在语言之间进行通信。
from: http://www.stackoverflow.com/questions/14047979/executing-python-script-in-php-and-exchanging-data-between-the-two 来自: http : //www.stackoverflow.com/questions/14047979/executing-python-script-in-php-and-exchangeing-data-between-the-two
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.