jar 包下载
<dependency> <groupId>jython</groupId> <artifactId>jython</artifactId> <version>2.1</version> </dependency>
实例
package com.curiousby.python.demo; import org.python.core.PyFunction; import org.python.core.PyInteger; import org.python.core.PyObject; import org.python.util.PythonInterpreter; /** * @author baoyou E-mail:curiousby@163.com * @version 2016年8月1日 下午1:05:36 *<pre class="brush:php;toolbar:false"> <dependency> <groupId>jython</groupId> <artifactId>jython</artifactId> <version>2.1</version> </dependency> *
结果:
立即学习“Java免费学习笔记(深入)”;
3
其他两种 调用方法:
a) 直接执行Python脚本代码
PythonInterpreter interpreter = new PythonInterpreter(); interpreter.exec("days=('mod','Tue','Wed','Thu','Fri','Sat','Sun'); "); ///执行python脚本
b)使用Runtime.getRuntime()执行脚本文件
Process proc = Runtime.getRuntime().exec("python D:\demo.py"); proc.waitFor();
python怎么学习?python怎么入门?python在哪学?python怎么学才快?不用担心,这里为大家提供了python速学教程(入门到精通),有需要的小伙伴保存下载就能学习啦!
Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号