Py4J 示例代码 (Python 调用 Java API),py4jpython,python代码>>>


python代码

>>> from py4j.java_gateway import JavaGateway>>> gateway = JavaGateway()                        # connect to the JVM>>> java_list = gateway.jvm.java.util.ArrayList()  # create an ArrayList>>> java_list.append('Hello ')                     # call ArrayList.add in the JVM>>> java_list.append('World')>>> java_list.append('Now')>>> liststr = gateway.entry_point.getListAsString(java_list[:-1])>>> print(liststr)Hello World

评论关闭