简体   繁体   English

如何将 arrays 从 NodeJS 传递到 Python 脚本?

[英]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.我想制作一个 electron 应用程序,它在后台调用 python 脚本。 Now I have the problem of passing an array of strings from javascript to python.现在我遇到了将字符串数组从 javascript 传递到 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您可以尝试使用json并使用 node.js 写入文件并让 python 从文件中读取

Python Python

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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