如何在php中优雅的地调用python程序

时间:2023-08-10 17:27:19

1.准备工作   安装有python和php环境的电脑一台。

2.书写程序。

php程序如下

如何在php中优雅的地调用python程序

如何在php中优雅的地调用python程序

如何在php中优雅的地调用python程序

我们也可以将exec('python test.py') 换成 system('python test.py')

区别是  system 有返回结果,exec没有返回结果

如何在php中优雅的地调用python程序

如何在php中优雅的地调用python程序

ps: 后记,如果是python 中有中文字符串,在php程序中要做编码转换处理。

iconv('gbk', 'utf-8', $output);

相关文章