擅长:python、mysql、java
<p>它可以直接使用Node完成,您可以使用<code>child_process</code>模块。请注意这是异步的。</p>
<pre><code>const exec = require('child_process').exec;
function execute(command, callback) {
exec(command, (error, stdout, stderr) => {
callback(stdout);
});
};
// call the function
execute('ping -c 4 0.0.0.0', (output) => {
console.log(output);
});
</code></pre>
<p>我鼓励您也看看<a href="http://npmjs.com" rel="noreferrer">npm</a>,有很多模块可以帮助您做您想要的事情,而无需调用python脚本。</p>