我尝试了InputStream并获取了我试图在事件单击侦听器上运行的“ freqJournal.py”的绝对路径。您对我可以在android studio中运行python代码有任何建议或方式吗?
我已经在Eclipse中尝试过该代码,而我的python代码正在那里运行。在将文件放入Android Studio中的目录中时,我仍然是新手。
try{
String user = "UserID = " + UserID;
String command = "python /src/main/assets/freqJournal.py";
Process p = Runtime.getRuntime().exec(command);
BufferedReader in = new BufferedReader(new
InputStreamReader(p.getInputStream()));
String ret = in.readLine();
Toast.makeText(getApplicationContext(), "value is : " + ret, Toast.LENGTH_LONG).show();
}catch (Exception e){
Log.i("file", "can't see it");
}
输出应为python代码,将发送包含matplotlib图的电子邮件。