在Python中执行php代码 [英] Execute php code in Python

查看:188
本文介绍了在Python中执行php代码的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

由于某种原因,我必须运行一个php脚本才能从Python获取图像.因为php脚本很大,而且不是我的,所以我需要几天的时间才能找到所使用的正确算法并将其转换为python.

For some reason, I have to run a php script to get an image from Python. Because the php script is very big and it is not mine, it will takes me days to find out the right algorithm used and translate it into python.

我想知道是否有任何方法可以运行带有少量参数的php脚本,该脚本可以在python中返回图像.

I am wonder if there is any way to run php script, with few parameters, which returns a image, in python.

推荐答案

示例代码:

import subprocess

# if the script don't need output.
subprocess.call("php /path/to/your/script.php")

# if you want output
proc = subprocess.Popen("php /path/to/your/script.php", shell=True, stdout=subprocess.PIPE)
script_response = proc.stdout.read()

这篇关于在Python中执行php代码的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆