试试这个:
cspr.stdout.setEncoding('utf8');cspr.stdout.on('data', function(data) { var str = data.toString(), lines = str.split(/(r?n)/g); for (var i=0; i<lines.length; i++) { // Process the line, noting it might be incomplete. }});请注意,“数据”事件不一定在输出的两行之间平均中断,因此一行可能跨越多个数据事件。



