首页 > 技术文章 > jsp调用Python

AbsolutelyPerfect 2017-11-20 11:14 原文

真是神奇,在我为python可视化的图表在jsp页面中不能动态更新的时候,老师告诉我也许能直接调用,竟然还有这种操作!!!

百度一下,再应用一下,真的成功了!

害怕!

<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ page import = "java.io.BufferedReader" %>
<%@ page import = "java.io.InputStreamReader" %>


<%
    Process proc = Runtime.getRuntime().exec("python C:\\Python\\ex3.py");
    BufferedReader in = new BufferedReader(new InputStreamReader(proc.getInputStream()));  
    String line;  
    while ((line = in.readLine()) != null) {  
        out.println(line);  
    }  
    in.close();      
    proc.waitFor();   
    out.println("end");
%>

 

学无止境啊!

推荐阅读