Running a .py file from Java

前端 未结 5 1571
春和景丽
春和景丽 2020-11-28 09:15

I am trying to execute a .py file from java code. I move the .py file in the default dir of my java project and I call it using the following code:

    Strin         


        
5条回答
  •  佛祖请我去吃肉
    2020-11-28 09:18

    You can run the python script

    Process p = Runtime.getRuntime().exec(PYTHON_ABSOLUTE_PATH, script_path)
    

    To get the PYTHON_ABSOLUTE_PATH just type

    which python2.7
    

    in terminal

提交回复
热议问题