Как получить переменную из файла PHP в подпроцессе Django (python)? - PullRequest
0 голосов
/ 07 января 2020

Существует такой файл php.

/* main_app/test.php */
/* I can't modify this file. */
<?
    $test_a = "this is test a.";
    $test_b = "this is test b.";
    $test_c = "this is test c.";
?>

и мой код python (views.py):

def point_charge(request):
    import subprocess
    proc = subprocess.Popen("php /main_app/test.php", shell=True, stdout=subprocess.PIPE)
    script_response = proc.stdout.read()
    print(script_response)
    return render(request, 'main_app/sub_pointcharge.html')

Я хочу получить значение test_a из python print.

Код, который я ожидаю, похож на ..

print(script_response.test_a)

это тест a.

Могу ли я?

спасибо.

Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...