简体   繁体   English

如何在android上运行python脚本进行输入并获取输出

[英]How to run python script on android for input and get output

I have a simple Python script which intakes a string and provides output as a string .我有一个简单的Python脚本,进水口前string ,并提供输出作为一个string I am totally a newcomer when it comes to coding or android app development.在编码或 Android 应用程序开发方面,我完全是一个新手。 Please suggest a way where I can give input to my Python code on an Android phone.请提出一种方法,让我可以在 Android 手机上为我的 Python 代码提供输入。

the process is as follows.过程如下。

  1. I copy a string from my phone我从手机中复制了一个string
  2. I paste in that android terminal/ app我粘贴在那个 android 终端/应用程序中
  3. It returns with output string that I need to copy.它返回我需要复制的输出string

Thanks in advance.提前致谢。

you can use pydroid, but i think there isnt what you want.你可以使用pydroid,但我认为没有你想要的。 if you want to make an app that requires an input from the user and calls your function, you can use kivy + buildozer.如果你想制作一个需要用户输入并调用你的函数的应用程序,你可以使用 kivy + buildozer。 kivy makes an application for windows or linux from python and buildozer copiles the application for android. kivy 从 python 为 windows 或 linux 制作应用程序,而 buildozer 为 android 编译应用程序。 but you need a machine or virtual machine with ubuntu, or maybe other distro, to use buildozer.但是您需要一台带有 ubuntu 或其他发行版的机器或虚拟机才能使用 buildozer。 just paste that on terminal.只需将其粘贴到终端上即可。

#!/bin/bash

# Install Python pip
sudo apt-get install -y curl
sudo apt-get install -y python3-distutils
curl https://bootstrap.pypa.io/get-pip.py -o get-pip.py
sudo python3 get-pip.py

# Dependencies with SDL2
# Install necessary system packages
sudo apt-get install -y \
    python-pip \
    build-essential \
    git \
    python \
    python3-dev \
    ffmpeg \
    libsdl2-dev \
    libsdl2-image-dev \
    libsdl2-mixer-dev \
    libsdl2-ttf-dev \
    libportmidi-dev \
    libswscale-dev \
    libavformat-dev \
    libavcodec-dev \
    zlib1g-dev

# Dependencies Kivy
sudo pip3 install cython

# Install Kivy
sudo pip3 install kivy

# Dependencies Buildozer
sudo apt install -y \
    build-essential \
    ccache \
    git \
    libncurses5:i386 \
    libstdc++6:i386 \
    libgtk2.0-0:i386 \
    libpangox-1.0-0:i386 \
    libpangoxft-1.0-0:i386 \
    libidn11:i386 \
    python2.7 \
    python2.7-dev \
    openjdk-8-jdk \
    unzip \
    zlib1g-dev \
    zlib1g:i386 \
    libltdl-dev \
    libffi-dev \
    libssl-dev \
    autoconf \
    autotools-dev
    cmake

# Install Buildozer
git clone https://github.com/kivy/buildozer.git
cd buildozer
sudo python3 setup.py install

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

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