由于最近在学习python,很想在java中调用,在网上查了一些资料,在此贴在这里,方便本身之后查询html
调用方式:java
引用 org.python包python
1 PythonInterpreter interpreter = new PythonInterpreter(); 2 interpreter.exec("days=('mod','Tue','Wed','Thu','Fri','Sat','Sun'); "); ///执行python脚本
执行py文件学习
1 PythonInterpreter interpreter = new PythonInterpreter(); 2 InputStream filepy = new FileInputStream("D:\\demo.py"); 3 interpreter.execfile(filepy);
使用Runtime.getRuntime()执行脚本文件,这种方式能够解决第一和第二种方式的第三模块找不到的缘由spa
1 Process proc = Runtime.getRuntime().exec("python D:\\demo.py"); 2 proc.waitFor();
以上信息是在 http://www.cnblogs.com/lmyhao/p/3363385.html 查看的,具体效果怎么样,在这个星期内去实现code