[英]exec command doesn't work with variables added, but works without variables variables added
I'm trying to execute python file made by CaryKH called jumpcutter.py
using child process 我正在尝试使用子进程执行CaryKH制作的名为
jumpcutter.py
python文件
This is a working function, where the exec command does work: 这是一个有效的函数,exec命令在其中起作用:
function executePython(){
const { exec } = require('child_process');
const path = require('path');
var input = document.getElementById('input').value
var output = document.getElementById('output').value
var silent = document.getElementById('silent').value
var sounded = document.getElementById('sounded').value
var margin = document.getElementById('margin').value
alert(input)
exec('python jumpcutter.py --input_file wow.mp4 --output_file wowcut.mp4 --silent_speed 999999 --sounded_speed 1 --frame_margin 1')
}
However, when I do this: 但是,当我这样做时:
exec('python jumpcutter.py --input_file ' +input ' --output_file ' +output ' --silent_speed ' +silent ' --sounded_speed ' +sounded ' --frame_margin ' +margin)
the code doesn't work entirely, so even the alert no longer works, even though it did prior. 该代码无法完全正常工作,因此即使警报已经生效,警报也不再有效。 I have already tried to store the console command in a variable called
text
but to no prevail. 我已经尝试过将控制台命令存储在一个名为
text
的变量中,但是并不占优势。
Thank you in advance for any assistance :) 预先感谢您的协助:)
the string concatenate is wrong 字符串连接错误
to concatenate multiple strings into one the syntax is: 将多个字符串连接为一个,语法为:
string1 + string2 + string3 + string4 + ....
so your code should be like this: 因此您的代码应如下所示:
exec('python jumpcutter.py --input_file ' + input +' --output_file ' +output+ ' --silent_speed ' +silent+ ' --sounded_speed ' +sounded+ ' --frame_margin ' +margin)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.