由於最近在學習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