-
Notifications
You must be signed in to change notification settings - Fork 224
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
json mode and run method #16
Comments
Simply set options using the second argument, like so: PythonShell.run('script.py', { mode: 'json' }); |
Yes. Ok. But how to transfer message? |
Can you clarify your question? What are you struggling with exactly? Basically, var python = PythonShell.run('script.py', { mode: 'json' });
// send a message
python.send({ hello: 'world' });
// receive a message from Python
python.on('message', function (message) {
// handle message sent from Python
} On the Python side, you simply read from stdin and write to stdout. # send a JSON message to node
print json.dumps(obj)
# receive messages
for message in sys.stdin:
# handle message sent from node |
I want to use this example: this example work only with args. |
Still having trouble? If not I'll close this. |
Is it possible to use PythonShell.run together with mode:JSON?
What is correct options structure?
The text was updated successfully, but these errors were encountered: