简体   繁体   中英

How can I call a python script with arguments from within Processing?

I have a python script which outputs a JSON when called with different arguments. I am looking for a way to call that script from within Processing and load the output using something like loadJSONObject()

The problem is that I don't know how to call the python script with arguments from within Processing.

Any tip will be appreciated, thanks!

One option, as pointed out in the comments, is to use open , and then load the file that generates the normal way.

Another -arguably much better- way is to not do this and to run your python script as services with a web interface instead, so that your python scripts sits listening on http://localhost:1234 , for instance, and your Processing sketch can simply load a file " http://localhost:1234/somefile?input=whatever " and not even care what is actually generating the content.

The upside there is also that you can run your script anywhere that can be reached via URLs, and those things don't need to rely on python being available as an executable.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM