将 python 的输出发送到 PHP 网页

Sending output of python to PHP webpage

下面是我在 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");