How to run python on the mobile phone, how to operate python on the mobile phone

Hello everyone, the editor will answer the following questions for you, how to operate python on the mobile phone, how to run python on the mobile phone, let us now take a look together!

1. The mobile browser runs python

The mobile browser runs python because the mobile browser and python are compatible with each other. The mobile browser can decompress and store and display the content data of python, so the mobile browser runs python.

2. How to program Python with mobile phone?

The python language is widely used, and I like to use it very much. In fact, we can also do python development and learning directly on our own mobile phone. We only need to configure the environment simply. How to use the mobile version of python .

First we can install qpython3 on the phone. Learning and using Python is fun. As it grows in popularity, there are more and more ways to make the computing world better than it is today.

Imagine building and running a Python app with just an Android mobile device and open source tools, whether it's developing a command-line tool to get your favorite articles from the Internet, or launching a program that runs directly on your handheld device, all These are all achievable. This will completely change the way you think about your mobile device, from a device that just lets you consume content to one that helps you be creative.

In this article, I'll demonstrate all the tools, packages, steps, and bits and pieces needed to run and test a simple Python application. I'm using the Flask framework to create a simple "Hello, World!" application running on a simple but powerful web server. Best of all, it all happens on your phone. No laptop or desktop required.

3. Can the python code be viewed on the mobile phone?

You can view Python codes on your mobile phone, as long as you have installed Python-related applications, you can view Python codes on your mobile phone. You can search for Python applications on Google Play or App Store, download and install them, and then you can view Python codes on your phone. You can also use Python Editor, which helps you write, edit and test Python code, and is available on your phone. Additionally, you can use the Python compiler, which compiles Python code into code that can run on your phone. In a word, you can view, edit and compile Python codes on your mobile phone to achieve your purpose.

4. How to input the value of n when the python3.9 mobile version is executed

The easiest way is as follows: n = int(input())
l = [int(input()) for _ in range(n)]
However, this has some problems: it will crash on invalid input.
It evaluates dangerous input - user can modify your program state. (Python 2.x)
The user can enter a floating point number and the program will not complain, it will just truncate it automatically. (Python 2.x)
Instead, you can use raw input and parse the result as an integer. You also need error handling in place. How errors are handled depends on the program.
You might find this function useful as a starting point: def getNumber(prompt = ''):
while True:
try:
return int(raw_input(prompt))
except:
print "Invalid input, try again."
Note that input and raw The behavior of typing changed between Python 2.x and Python 3.x. The input function of python3.x behaves like the original input function of python2.x.

5. How does the python program run on the phone?

You can use the QPython app to run python programs on your phone.

QPython is a scripting engine that can run python programs on Android devices. You can download and install it in the app store, and then you can run Python terminals and Python scripts on your phone, which is very convenient.

QPython app main interface

QPython runs the python terminal

Please accept, thank you.

6. How to run Python on the mobile phone, the code runs on the computer but not on the mobile phone

How to make the python script written by myself on the computer run on the mobile phone or android system

You can install a Python emulator, such as QPython.

After installing this apk, you can run Python scripts on Android.

About QPython3L, online search instructions:

QPython - Instructions for use

A. Panel

Figure - Startup Panel

QPython is the Python engine on the Android system. With QPython, you can use Python on the Android system very well.

QPython requires you to grant system permissions such as network, bluetooth, and geographic location, so that you can use these features for programming. Of course, QPython does not require you to grant permissions such as reading mobile phone information, reading text messages, and accessing mobile phone accounts, so you cannot use corresponding functions. Some SL4A-related interfaces. If you need more open permissions to program, please use the more open QPython3.

Of course, whether it is QPython or QPython3, we will not use these permissions to collect your personal information, they are only used when you program. (Note: we use network permissions to check if it is the latest version)

This guide is written based on the latest version 1.0.4 of QPython. If you are not using the latest QPython, please update it as soon as possible.

After installing QPython, run it, and you will see the startup interface like in the picture.

start up button

After clicking the button with the Python logo in the middle of the screen, the run launch menu will be displayed, you can: Read the code from the QRCode code picture (a fun way to share and distribute code, you can create a QRCode with QPython's QRCode generator image) run script in device* run project in device

Figure - Start button

If you are using version >=0.9.8, you can run php_console.py in the script directory to install many third-party libraries.

If you want to run a specific script or program after clicking the launch button, instead of showing the selection menu like the default, you can do it by "Set Default Program" in the settings page.

Developer Tools Panel

If you swipe left on the panel for the launch button, you'll see another main panel. For developers, it will be more practical and convenient.

Figure - Developer Panel

There are many useful functions here:

Next, let's look at the console and editor together:

B. Console and Editor

Figure - Console

If you long press the console or editor icon on the developer panel, you can also create a shortcut on the desktop that allows you to go directly to the console or editor.

console

Figure - enter the console from the notification bar

As I said before, QPython has the same Python console as the PC side, and many users are used to using it to explore programming object properties, experiment with syntax or test their existing ideas. You can type commands directly into the terminal and let the Python interpreter execute them. Click the "+" icon in the upper right corner of the console to create a new terminal window, and click the arrow in the upper left corner to display the list of currently opened console windows, so that you can switch to a different console. If you want to close the console, click the close button "x".

Please note that after opening the console, a small terminal icon will appear in the message prompt column, unless you have closed the terminal. If you open the prompt window and click the small terminal icon, you can go back to the terminal again.

editor

Figure - Editor

The embedded editor of QPython allows you to develop Python conveniently in your palm. It has the following functions:

Editors allow you to enter and edit text. You can develop your scripts, save and run them. The editor supports Python syntax highlighting and line counting.

While typing, you can easily control the level of compression (important for Python) via the first two icons "<" and ">" in the bottom control bar. Next is "Jump to? Line", click the icon, enter the number of lines to quickly jump to the line you want to jump to, and then save and save as, and then run, undo, search, recently open , code snippets and editor settings buttons. Don't forget that there are also Open and New buttons on the right side of the top navigation.

When saving, don't forget to add the ".py" suffix to the suffix name, because the editor will not automatically complete it.

C. Procedures

In the program you can manage your scripts and projects, which are located in /sdcard/com.hipipal.qpyplus/scripts and /sdcard/com.hipipal.qpyplus/projects respectively.

After entering the program, when you press and hold a script or project, you can create a shortcut to the corresponding script or project on the desktop. After you create their shortcuts, you can start them directly from the desktop.

screenplay

Figure - Script and click action options

A script is a simple file, and the script is located in the /sdcard/com.hipipal.qpyplus/scripts directory. If you want your own scripts to appear here, put them in this directory.

After clicking the script, you can do the following:

project

Figure - Items and long press to create shortcuts

The project contains main.py as a directory of the default startup script. At the same time, you can put third-party dependent libraries or resources in it. If you want your project to be automatically discovered by QPython, please put it in /sdcard/com .hipipal.qpyplus/projects directory.

When you click on an item, you can:

D. library

The library is an important part of QPython. Through the library, you can install the Python library. Here, you can install many libraries written in pure Python from the official Pypi source. Compiling the chain tool and failing)

Figure - Library

Manually install the library

Usually, you can also complete manual installation by placing your library in the /sdcard/com.hipipal.qpyplus/lib/python2.7/site-packages directory.

But if you have .so files in your library, and you have tried to place them in a directory on the sdcard and it cannot be loaded successfully, you need to try this step: install them to /data/com.hipipal.qpyplus/files/lib/ python2.7/site-packages/ directory.

Install from QPypi

Figure - Install from QPypi

We provide a QPypi web service and publish several libraries. After clicking the details, you can install the library by clicking "Install" (it actually calls the pypi tool to complete this operation).

Install from official Pypi

Figure - Install from Pypi

After clicking, you enter the pypi command interface, which calls the pypi tool to allow you to install it yourself. You only need to enter the pip command, such as pip install [HTML_REMOVED], to install the library. However, it should be noted that currently it cannot Install libraries with c/c++ etc. files that need to be edited, because Android doesn't have a toolchain available for compilation by default.

Generally speaking, packages installed through QPypi or Pypi will be installed in the /data/com.hipipal.qpyplus/files/lib/python2.7/site-packages/ directory.

E. Community

Figure - QPython Community

You can meet other QPython users in the community, you can ask questions, participate in topic discussions, submit bugs/suggestions to developers, etc.

In addition, we will actively promote QPython to be fully open source eventually, so enthusiastic users are welcome to join us, we urgently need your help in the following areas:

other

  • Console — yes, it's the usual Python console where you can interact directly with the Python parser

  • Editor — QPython's built-in code editor allows you to edit and run code directly in the QPython application

  • Programs - Here you can find your QPython scripts and projects, after the default installation, there will be some sample scripts and projects

  • Libraries — you can install many Python libraries here

  • Community — through the community, you can better learn and use QPython here, and participate in the construction of QPython

  • open a file

  • Create a new file or project

  • Left indent 4 spaces

  • Right indent 4 spaces

  • jump to the specified line

  • save current file

  • Run the current Python file

  • undo last action

  • Search by keyword

  • Show list of recently edited files

  • insert code snippet

  • Set editor default behavior

  • run: run the script

  • Open: Edit scripts with the embedded editor

  • rename: rename the script

  • delete: delete the script

  • run project

  • Open the project with the resource browser to view its resources

  • rename project

  • delete this item

  • About QPypi service We are currently maintaining QPypi service. Third-party library developers are welcome to contact us. We can create a QPypi account for you, and then you can use the pypi system to maintain your Python library in QPypi by yourself.

  • Language Internationalization

  • Help us test and submit test feedback

  • Feedback questions and submit good suggestions

  • Build a local community, initiate local technical talks, and learn together

7. Can the mobile phone use python?

method/step

  • First we can install qpython3 on the phone.

    Please click to enter a picture description

  • Then we can directly select "Terminal".

    Please click to enter a picture description

  • Here we can directly enter the execution code line by line.

    Please click to enter a picture description

  • We can also choose to go into the "Editor".

    Please click to enter a picture description

  • Enter our python script code directly.

    Please click to enter a picture description

  • Then click the "Execute" button at the bottom to run the script and output "Hello".

    Please click to enter a picture description

    Please click to enter a picture description

  • We can also choose to enter the "Program", there are many cases for us to learn and use.

    Please click to enter a picture description

  • After clicking, select "Run" to execute the program, and select "open" to view the code of the case for easy learning.

    Please click to enter a picture description

    Please click to enter a picture description

     

Guess you like

Origin blog.csdn.net/chatgpt001/article/details/129106184