passing data between java and python

前端 未结 4 836
天命终不由人
天命终不由人 2021-01-03 02:17

Apologies if my question is noob. I\'m running Django 1.2 with pgsql 8.4 and I\'m required to run a Java program after getting the inputs from the user, does some calculatio

4条回答
  •  离开以前
    2021-01-03 02:45

    If all you are doing is calling Java for some calculations, then subprocess is the easiest way, but I just wanted to throw another option out there.

    JPype is a package that lets you run a JVM inside your Python program while calling the Java code as if it were Python (example).

    That is, it's like Jython in that you call Java code directly and like subprocess in that you are actually running CPython. Consider JPype if for some reason the Java code is not easy to call from a shell script (aka, subprocess) or if a lot of two-way communication is necessary.

提交回复
热议问题