首页 > 解决方案 > 通过jython我想从java执行一个python文件,并传递执行python文件所需的参数文件

问题描述

package Test_2.Test_2;

import org.python.core.PyInstance;  // importo jython

public class PythonHello {

    public static void main(String[] args) {
        
        // TODO Auto-generated method stub
         
              PythonCaller ie = new PythonCaller();  // istanzio la classe pythoncaller
              
              JsonMakeString JsonString = new JsonMakeString();  
                      
              String StringForPython = JsonString.JsonString();
              
              ie.execfile("MAIN.py");   

              PyInstance hello = ie.createClass("Main", StringForPython);  // Main is the class 

              hello.invoke("Run");   // Run is the method I want to run
              
           }

}

我想了解如何传递实例化 Main 类所需的参数

标签: javapythonparametersjython

解决方案


推荐阅读