一、java 代码
package com.Service;
import java.io.BufferedReader;
import java.io.InputStreamReader;
public class callPy {
public void runCallpy() {
try {
//Process pr=Runtime.getRuntime().exec(args1);
String url="http://blog.csdn.net/thorny_v/article/details/61417386";
System.out.println("start;"+url);
String[] args1 = new String[] { "python", "E:\\python\\PythonApplication1\\PythonApplication1\\gis\\javaCallpy.py", "a","b","c"};
Process pr=Runtime.getRuntime().exec(args1);
BufferedReader in = new BufferedReader(new InputStreamReader(
pr.getInputStream()));
String line;
while ((line = in.readLine()) != null) {
System.out.println(line);
}
in.close();
pr.waitFor();
System.out.println("end");
}
catch (Exception e) {
e.printStackTrace();
}
}
}
二、ptyon代码
# -*- coding: utf-8 -*-
import sys
if __name__ == '__main__':
for i in range(1, len(sys.argv)):
pra = sys.argv[i]
print pra