Java执⾏Python脚本并传参Java代码:
public class JavaExePython {
public static void run(String filePath, String param) throws IOException, InterruptedException {
String[] argv = {filePath, param};
PythonInterpreter.Properties(), Properties(), argv);
PythonInterpreter interpreter = new PythonInterpreter();
PySystemState sys = Py.getSystemState();
sys.path.add("C:\\workspace\\python\\mypython");
sys.path.add("C:\\Python27\\Lib\\site-packages");
}
}
Python 代码:
# -*- coding: utf-8 -*-
import json
import sys
del import Model
from lsheet import ExcelSheet
from lutil import ExcelUtil
def thrall(param):
eu = ExcelUtil('filename.xls')
dicts = {
python转java代码
'r1': json.loads(param)
}
model_key = 'thrall'
excelsheet = ExcelSheet(eu, 'Thrall项⽬异常列表', dicts, Model, model_key)
# 保存⾄excel
if __name__ == '__main__':
thrall(sys.argv[1])

版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系QQ:729038198,我们将在24小时内删除。