I am very new to php and I am quite understandably how Python does PHP contrast Now I know how to pass a variable, but I am still trapped and can not find any answer on this:
Php calls a Python script (that part works) Which gives a list of strings. I want to process this list in php.
When I try:
print mylist in myscript.py, then: < Pre> $ result = exec ('python myscript.py') It seems that php considers $ a string as a result (which I think Understandable).
I understand that maybe Jason may or may help me to use a dictionary instead of a list in Python, though I do not know how to fix it.
If someone can help, it will be appreciated! Thanks!
For example:
myscript.py Import json D = {'foo': 1, 'baz': 2} print json.dumps (D) myscript Php & lt ;? Php $ result = json_decode (exec ('python myscript.py', is true); The result of the result ['foo'];
No comments:
Post a Comment