So I've been searching everywhere and couldn't find a proper example that can execute a node js app file from Python, and after execution, stores the result in a varable in python.
This is because I don't want to transfer my whole source code from Py to Js; plus I prefer Python better.
Any help would be appreciated.
The format of the Python and NodeJs variables being not quite the same, it is not possible to simply caste a variable from one language to the other...
Nevertheless, I have some ideas :
Use a file as a buffer (write the result with js in the file, then read it with Python)
Use a key-value database, such as Redis or an asynchronous message queue, such as RabbitMq .
Use low-level modules to make a gateway in C / C++. https://docs.python.org/3/extending/extending.html (Python) + https://github.com/nodejs/node-gyp (NodeJs). This solution being nevertheless a bad idea (I think).
You can also try to create separate modules (each in a language) and have a real micro-component approach. This would be the best approach.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.