I have buffer json and write to python in nodejs this:
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();
and i'm read line in python this :
label = sys.stdin.readlines()
print(label)
#OUTPUT : ['["a","b","c","d"]']
How do I do convert is ['["a","b","c","d"]'] to array in python for use it ? Thanks!
Use json.load
:
import json
label = json.load(sys.stdin)