我有两个密码snippets:- 你知道吗
1)获取\u pos \u 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的形式得到输出。有人能帮我解释一下这段代码有什么问题吗?我用的是MacOSXElCapitan和PHP7
我对PHP了解不多,但您可能需要研究如何使用sys.stdout将python脚本的输出管道化到PHP脚本中
相关问题 更多 >
编程相关推荐