【问题标题】:Unable to access python array from php无法从 php 访问 python 数组
【发布时间】:2016-10-28 15:07:51
【问题描述】:

我有两个代码 sn-ps:-

1) get_pos_tags.py

import sys
import json
from nltk.tokenize import word_tokenize
from nltk.tag import pos_tag

def getPOSTags(sentence=sys.argv[1]):
    sentence_s=str(sentence)
    word_token=word_tokenize(sentence_s)
    print word_token
    word_POS_tags=pos_tag(word_token)

if __name__=='__main__':
    getPOSTags()

2)test.php

<?php
$sentence="I became the king of rome";
echo("python get_pos_tags.py "."'".$sentence."'",$output);
var_dump($output);

当我在 xampp 上运行 test.php 时,我收到 xampp 的输出为 null 而我应该以 python List 的形式获得输出。谁能帮忙看看这段代码有什么问题?我正在使用 MAC OS X El Capitan 和 PHP7。

【问题讨论】:

    标签: php python xampp


    【解决方案1】:

    我不太了解 PHP,但您可能希望使用 sys.stdout 将 Python 脚本的输出通过管道传输到 php 脚本中

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2013-12-15
      • 2016-11-12
      • 1970-01-01
      • 1970-01-01
      • 2017-04-13
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多