java:getRuntime().exec()将参数传递给Python程序
我试图将run和pass参数传递到python程序中,但遇到了问题。 以下是我现在正在做的:java:getRuntime().exec()将参数传递给Python程序,java,python,parameter-passing,Java,Python,Parameter Passing,我试图将run和pass参数传递到python程序中,但遇到了问题。 以下是我现在正在做的: String[] testCases=readIn("C:\\xampp\\htdocs\\development\\"+folder+"\\testCases.txt"); String arguements=""; for(int i=0; i<testCases.length; i++) {
String[] testCases=readIn("C:\\xampp\\htdocs\\development\\"+folder+"\\testCases.txt");
String arguements="";
for(int i=0; i<testCases.length; i++)
{
if(i==0)
{
arguements=testCases[i]+" ";
}
else
{
arguements=arguements+testCases[i]+" ";
}
command= new String[]{"C:\\Python27\\python.exe","C:\\xampp\\htdocs\\development\\"+fileName, arguements};
Process process=Runtime.getRuntime().exec(command);
我很确定我传递的论点是正确的。我是否需要以某种方式指出它们是Python代码将使用的参数?您确实传递了错误的参数。您需要在命令数组中将每个参数作为字符串传递。e、 g
command = new String[arguments.length + 2];
command[0] = "C:\\Python27\\python.exe";
command[1] = "C:\\xampp\\htdocs\\development\\" + fileName;
System.arraycopy(arguments, 0, command, 2, arguments.length);
尝试打印到达控制台的最终命令,并在命令行中执行该命令。 你将能够找出确切的错误