java 調用執行jpython腳本 原

        //pythonScript python腳本字符串     

        String        pythonScript;

        ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(pythonScript.getBytes());

        Properties props = new Properties();

        props.put("python.home", "C:\\python2");
        props.put("python.console.encoding", "UTF-8");
        props.put("python.security.respectJavaAccessibility", "false");
        props.put("python.import.site", "true");
        Properties preprops = System.getProperties();
        PythonInterpreter.initialize(preprops, props, new String[0]);
        interpreter = new PythonInterpreter();
        interpreter.execfile(byteArrayInputStream);

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章