const readline = require("readline");
const rl = readline.createInterface({
input: process.stdin,
output: process.stdout,
});
var inputArr = [];
var lineNum = 0;
rl.on("line", function (line) {
inputArr.push(line);
var n = parseInt(inputArr[0]);
if (lineNum == n) {
inputArr=inputArr.slice(1);
rl.close();
} else {
lineNum++;
}
});
rl.on("close", function () {
console.log(inputArr)
console.log("程序结束");
//处理
process.exit(0);
});
标签:nodejs,process,var,lineNum,命令行,rl,readline,inputArr,输入
From: https://www.cnblogs.com/badpear/p/17155378.html