This is the first in a series of articles on Pyhon, which focuses on the basic concepts of Python and how to install it.
Dry goods full of advice collection, need to use often look. If you have any questions or needs, please feel free to leave a comment.
upfront
Python language is not new to you readers, even if you have not used Python, you must have heard of it. The phrase "life is short, I use Python" is the mantra of many Python fans, and a powerful retort to Python's black fans. As the first in a series of articles, this article is an unusually simple one. In this article, we will start from
- What is Python?
- How to install Python environment?
- What are the advantages and disadvantages of Python?
- What are the application scenarios for Python?
These four aspects are elaborated.
What is Python
Python is an open source, free, general-purpose scripting programming language. It requires parsing lines of code into machine code that is recognized by the CPU at runtime. It is a parsing language, what is a parsing language? What is a parsing language? It is a language that parses source code into machine code line by line through a parser at runtime. C language, C++, etc. is a compiled language, that is, through the compiler to compile all the source code into binary instructions at once, to generate an executable program. The advantage of parsed languages over compiled languages is that they are naturally cross-platform, coding once and running everywhere.
How to install Python?
Previously introduced the basic concepts of Python, the next is to introduce how to install Python, Python language is currently divided into and two versions, and is not compatible. At present, the mainstream are using Python3, which is an interpreted language, so different platforms need different interpreters, because the machine code recognized by each platform is different. Since the local environment is Max OS, here we focus on how to install Python3 in Max OS environment.
Installing Python3 under Max OS
Common Installation
Max OS comes with an integrated Python2 development environment by default. You can see the default Python version by using the command python in the terminal.
If you want the environment to be installed on your computer, just enter the python3 command.
The official download URL is: /downloads/, and you will see the latest release, if you want to download other versions, you can come down to find the information shown in the following figure, the current latest version is python 3.9.5 version.
Click the Download button to go to another page.
On this page click on the Download macOS 64-bit Intel installer button to download it. Click on the link and after the download completes you will get a python-3.9.5-macosx10. installer.
Double-click python-3.9.5-macosx10. to enter the Python installation wizard, and follow the wizard step-by-step down the installation path, leaving everything as default.
After the installation is complete, enter the command python3 in the terminal to view the Python version information after the installation, which normally appears as shown in the following figure.
This will allow you to see where python is installed.
import sys print()
Installation via Homebrew
There is another quick way to install software in Mac OS, and that is by way of Homebrew, a package manager for installing various software. We are familiar with package managers such as the wget package manager in linux. The main purpose of the package manager is to resolve the dependencies of the software during the installation process.
If your computer does not have Homebrew installed, it is also very simple, just through the following command to install Homebrew, about the detailed use of Homebrew can refer to this articleSteps to install Homebrew on Mac M1It works really, really well.
/bin/bash -c "$(curl -fsSL /Homebrew/install/HEAD/)"
Once you have installed Homebrew, enter the following command in the terminal:
brew install python3
It will be easy-easy to install python.
What are the advantages and disadvantages of Python?
After you've finished installing Python, it's customary to go over the pros and cons of Python next.
vantage
- The syntax is simple and Python is not as strict about code formatting
- Can be cross-platform, Python is an interpreted language, interpreted languages are generally cross-platform (good portability).
- Powerful, Python has many modules, basically realizes all the common functions, from simple string processing, to complex 3D graphics drawing, with the help of Python modules can be easily completed.
drawbacks
- It runs slowly because Python is an interpreted language and needs to parse the source code line by line into machine code at runtime. So it runs slowly.
- Code encryption is difficult, unlike compiled languages where the source code is compiled into an executable program, Python runs the source code directly, so it is difficult to encrypt the source code.
What can Python do?
Web Application Development
For example, the domestic Douban is developed through Python, and the foreign Youtube is also developed through Python to automate the operation and maintenance.
Typically, system administration scripts written in Python are superior to regular shell scripts in terms of readability, performance, code reuse, and extensibility. Web crawlers
Technically speaking, Python provides a number of tools that serve to write web crawlers, such as urlib, Seleium, etc. It also provides a web crawler framework, Scrapy.
summarize
This article briefly introduces the concepts of the Python language and its installation. We hope it will be helpful to our readers.
To this article on the python introductory course, the first lecture of the installation and the advantages and disadvantages of the introduction of the article is introduced to this, more related to the installation of Python tutorial content, please search for my previous articles or continue to browse the following related articles I hope that you will support me more in the future!