0
實際上,我可以運行這個python腳本,並且此腳本在終端中運行時創建csv文件。但是,當我在nodejs後端運行這個文件不能創建一個csv文件。我在哪裏犯錯誤?Nodejs使用PythonShell運行python腳本
這裏是pythonshell主頁:https://github.com/extrabacon/python-shell
var options = {
mode: 'text',
scriptPath: './views',
args: [informations["camera_id"], informations.start_s, informations.start_min, informations.start_h, informations.start_d, informations.start_mon, informations.start_y, informations.end_s, informations.end_min, informations.end_h, informations.end_d, informations.end_mon, informations.end_y]
};
var pyshell = new PythonShell('historical_inquiry_1.py', options);
pyshell.on('message', function (message) {
console.log("script message : ",message);
});
這裏是Python腳本(測試是一個數組):
...
with open("test.csv", "w") as text_file:
text_file.write(test)
...
事實上,我會用這個巨大的查詢結果。正常的方式結果是超時。你可以給我的錯,我們更好的方式來採取巨大的MongoDB查詢結果。 在此先感謝。