I'm trying to get data from Python script:
import pymorphy2
import json
import sys
morph = pymorphy2.MorphAnalyzer()
butyavka = morph.parse(sys.argv[1])[0]
for item in butyavka.lexeme:
print(item.word)
PHP code:
<?php
chdir('C:\\Users\Michael-PC\AppData\Local\Programs\Python\Python35-32');
$out;
passthru('python WordAnalizator.py "слово"', $out);
echo($out);
?>
If I use console, it make correct response, like:
But in PHP I have only first word:
Whats wrong?
This is obvious encoding problem (Russian letters become unreadable). So, try to set (i.e. change default) encoding in the PHP code, e.g. add to header usage of Unicode:
header('Content-Type: text/html; charset=utf-8');
If charset=utf-8
does not help, try charset=windows-1251
instead.
UPDATE:
Do not forget to save your file (PHP code in UTF encoding for utf-8, or ANSI for windows-1251)