my php code:
<?php
$data = array('as', 'df', 'gh');
$result=shell_exec("start test.py ".escapeshellarg(json_encode($data)));
?>
test.py code:
import sys
import json
try:
print json.loads(sys.argv[1])
except:
print "ERROR"
print
raw_input()
it's failing to try and showing ERROR. while if change my python code to this:
import sys
try:
data=sys.argv[1]
except:
print "ERROR"
print data,
raw_input()
i'm getting the output as: [ as , df , gh ]
as i'm passing a json encoded data, i should be able to decode it with python's json.loads() method. but why it's not working?