0
美好的一天大家,如何在一個NodeJS文件中包含python腳本?
通過這個社區的推薦,我已經安裝shelljs,如npm install shelljs --save
到我的應用程序文件夾。
現在我正在研究如何在我的nodejs文件中實現它。
下面是我的NodeJS文件
var express = require('express');
var router = express.Router();
var COMPORT = 5;
var command = 'option1';
下面這個我想包括我的python腳本
import serial
ser = serial.Serial()
ser.baudrate = 38400 #Suggested rate in Southco documentation, both locks and program MUST be at same rate
// COMPORT is a variable that stores an integer such as 6
ser.port = "COM{}".format(COMPORT)
ser.timeout = 10
ser.open()
#call the serial_connection() function
ser.write(("%s\r\n"%command).encode('ascii'))
因此,我的問題是你如何包括與中定義的變量,這個python腳本nodejs包含在與nodejs相同的文件中的腳本中。
在nodejs上運行的此應用程序將通過電子封裝爲可執行的桌面應用程序。