简体   繁体   English

将python脚本执行到android

[英]execute python script to android

I am trying to create a program to android which will call a python script. 我正在尝试为android创建一个程序,该程序将调用python脚本。 In specific i want to connect the android activity with tcp connection with a java server( i create this) and then execute a script code with some args... In java this code executed perfectly 具体来说,我想将与TCP连接的android活动与java服务器连接(我创建了此),然后使用一些参数执行了脚本代码。

String pythonScriptPath = "test.py";
String[] cmd = new String[2];
cmd[0] = "python";
cmd[1] = pythonScriptPath;
Runtime rt = Runtime.getRuntime();
Process pr = null;
try {
    pr = rt.exec(cmd);
} catch (IOException e) {
    e.printStackTrace();
}

but python command exists on the system but in android there is error... can i install an interpreter? 但是系统上存在python命令,但是在android中有错误...我可以安装解释器吗? thank you very much 非常感谢你

One way is to use Kivy : 一种方法是使用Kivy

Open source Python library for rapid development of applications that make use of innovative user interfaces, such as multi-touch apps. 开源Python库,用于快速开发利用创新用户界面的应用程序,例如多点触控应用程序。

Kivy runs on Linux, Windows, OS X, Android and iOS. Kivy可在Linux,Windows,OS X,Android和iOS上运行。 You can run the same [python] code on all supported platforms. 您可以在所有受支持的平台上运行相同的[python]代码。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM