如何将缓冲区 stringify 从 node.js 转换为 python 中的数组

how to convert buffer stringify from node.js to array in python

我有缓冲区 json 并在 nodejs 中写入 python:

const python = spawn("python", ["index.py"]);
//label = ["a","b","c","d"]
let label = Buffer.from(JSON.stringify(label)); //<-----------------HERE
python.stdin.write(label); //<-----------------HERE
python.stdin.end();

我在 python 中阅读了这行 :

label = sys.stdin.readlines()
print(label)
#OUTPUT : ['["a","b","c","d"]']

如何将 ['["a","b","c","d"]'] 转换为 python 中的数组以供使用它 ?谢谢!

使用json.load:

import json

label = json.load(sys.stdin)