简体   繁体   中英

How to pass arrays from NodeJS to a Python script?

I wanted to make an electron app that calls a python script in the background. Now I have the problem of passing an array of strings from javascript to python. I already read about a solution using a flask-server but is this a good way of doing this, or is there a more efficient way?

You can try to use json and use node.js to write to a file and let python read from the file

Python

import json
with open("data.json",'r') as f:
    data = json.loads(f.read())
    f.close()
print(data)

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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM