java代码:
public void dumps(String data) {
ClassPathResource classPathResource = new ClassPathResource("/python/dumps.py");
try {
String path = classPathResource.getFile().getAbsolutePath();
String[] args = new String[] {"python", path, data};
Process proc = Runtime.getRuntime().exec(args);
BufferedReader in = new BufferedReader(new InputStreamReader(proc.getInputStream()));
String line;
while ((line = in.readLine()) != null) {
System.out.println(line);
}
in.close();
proc.waitFor();
} catch (Exception e) {
e.printStackTrace();
}
}
python代码:
import sys
import pickle
if __name__ == '__main__':
param = sys.argv[1]
bin = pickle.dumps(param)
print(bin)
输出结果为空,请教下如何获取到pickle.dumps()返回的二进制数据呢