将python的输出发送到PHP网页



下面是我在Python中的代码。我的讲师要求我是否可以将fanspeed.output[‘fan’]发送到PHP。例如,我在xampp上创建了一个网页,然后我需要将python的输出发送到网页,该网页将在网页上显示输出。我在网上搜索了一下,找不到解决问题的有效方法。有人能帮忙吗?

temp = int(input("temp="))
hum = int(input("hum="))
fanspeed.input['temperature'] = temp
fanspeed.input['humidify'] = hum
fanspeed.compute()
fanspeed.output['fan']
fan.view(sim=fanspeed)
print("Fan speed =",fanspeed.output['fan'])

最简单的方法是通过shell_exec调用python脚本。

像这样的

<?php
echo shell_exec("python /path/to/your/python/script.py");

最新更新