ProcessBuilder cannot run python script with arguments

前端 未结 1 1791
梦毁少年i
梦毁少年i 2021-01-16 13:54

Ok, so I have a python script that I am running through ProcessBuilder. Everything is working fine. The issue I am having is whenever I pass arguments into the python script

相关标签:
1条回答
  • 2021-01-16 14:01

    Pass two separate arguments to ProcessBuilder instead of concatenating --arg1 and argumentValue:

    ProcessBuilder builder = new ProcessBuilder("C:\\Python33\\python.exe",
                                                "-u",
                                                "C:\\...\\script.py,
                                                "--arg1",
                                                "argumentValue");
    

    Otherwise the program to be executed will see a single argument --arg1 argumentValue that it does not recognise.

    0 讨论(0)
提交回复
热议问题