如何从 Processing 中使用参数调用 python 脚本?

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

我有一个 python 脚本,它在使用不同的参数调用时输出 JSON。我正在寻找一种从 Processing 中调用该脚本并使用 loadJSONObject()

之类的方法加载输出的方法

问题是我不知道如何使用 Processing 中的参数调用 python 脚本。

任何提示将不胜感激,谢谢!

如评论中所指出的,一种选择是使用 open,然后加载以正常方式生成的文件。

另一个 - 可以说更好 - 方法是不这样做,而是 运行 你的 python 脚本作为具有网络界面的服务,这样你的 python 脚本就可以监听在 http://localhost:1234, for instance, and your Processing sketch can simply load a file "http://localhost:1234/somefile?input=whatever" 上,甚至不关心实际生成内容的内容。

还有一个好处是您可以 运行 您的脚本 任何地方 可以通过 URL 访问,并且这些东西不需要依赖 python 作为可执行文件可用。