The first is installing and configuring the environment
There are two ways to install and configure Python:
One is by installing Anaconda, a package management tool that brings together a lot of information about Python, including tripartite libraries, websites and blogs. Anaconda also features libraries for data science and deep learning that are easy to install.
Another option is to manually install Python, along with IDE tools such as PyCharm
As an Android developer, I initially recommended using the second method, mainly because PyCharm and Android Studio are similar in interface and function and can be adopted quickly.
Install Python and PyCharm
- The Anaconda interface
Python download address: www.python.org/downloads/
It is important to note that Python3 is now very popular, so just download and install the latest version of Python3.x
Once installed, open the terminal and type PYTHon3 without error to indicate that the installation is successful
- PyCharm
PyCharm download address: www.jetbrains.com/pycharm/dow…
Download a community version of PyCharm, which is free
PyCharm runs the first Python
When you open PyCharm, you’ll see that this is exactly the same Android Studio we’ve been using.
PyCharm includes terminals that can execute shell commands directly, and Python terminals that can execute Python code directly:
Write your first Python program
First we’ll create a new Python file, one that ends in.py
Once you’ve created the file, you’re ready to write Python code. Here’s a simple example: output ‘Hello world’
The contents of the file are as shown in the figure below. You need to specify the encoding format of the file and declare the main entry if you want to execute the file. Type main directly into the code and the code will be prompted, very convenient
Once the code is written, let’s run it. Run can be run directly from the terminal. Run the python3 xxx.py command. An even faster way is to use the Run icon directly from Pycharm, just like we did with the Android project. But before running, you need to configure the running environment of the following code.
Finally, click the Run icon to execute the Python program we just wrote.
Some common Settings
Sets the comment template at the beginning of the file
When we create a new file, we usually need to annotate some information, such as creation time, author, function, etc. This can be done using templates, similar to Android Studio.
With this setting, each new Python file will have a comment header
Add new tripartite libraries
We will definitely need to add a lot of tripartite libraries in our development, and Pycharm is very easy to install:
Modify Pycharm theme and font etc
This setup is similar to Android Studio
Everything else is similar to Android Studio, such as shortcuts, and you can feel them when you use them.