How do I parse a dict output from a python script to a PHP array? My PHP file contains the line exec('/bin/python ~/somescript.py', $out, $err);. And my python script prints a dict with something like
d = {0: "a", 7: "d", 23: ["e", "z"]}
print(d)
But this doesn't work, $out[0] in my PHP file is just a really long string an array. I've also tried to use print(json.dumps(d)), same result (but with escaped " ).
json.loads(d)as.dumpsis used for encoding a python object to a json string (what I need). And.loadsis used for decoding a json string to a python object. See docs.python.org/3/library/json.html$outis the output of the python script. See php.net/manual/de/function.exec.php.