Python Basic knowledge learning series blog , Continuous updating
Python By Guido of the Dutch Society for mathematical and computer science research · Van rosum On 1990 It was designed in the early 's , As a course called ABC A substitute for language . Python Provides efficient advanced data structure , It's also a simple and effective way of object-oriented programming .Python Syntax and dynamic types , And the nature of interpretative language , Make it a programming language for scripting and rapid application development on most platforms , With the continuous update of the version and the addition of new language features , Gradually used for independent 、 Development of large projects .
Python The interpreter is easy to extend , have access to C Language or C++( Or something else can be done through C Calling language ) Expand new functions and data types . [4] Python It can also be used as an extensible programming language in customizable software .Python Rich library of standards , Provides source code or machine code for each major system platform .
  2021 year 10 month , Compiler for language popularity index Tiobe take Python Crowned the most popular programming language ,20 Put it in... For the first time in years Java、C and JavaScript above .
Python It's a cross platform 、 Open source 、 Free of charge 、 Interpretive advanced programming language said . In recent years Python The momentum is rapid , 2020 year 12 Of the month TIOBE The ranking of programming languages has been promoted to No 3 name , And in the IEEE Spectrum released 2020 Programming languages of the year , Python continuity 4 Won the championship in . in addition , Python It's widely used , Such as Web Programming 、 Graph processing 、 Hacking 、 Big data processing 、 Web crawlers and scientific computing , Python Can be realized . As Python The beginning of development , This chapter will begin with a study of Python Some basic contents that need to be understood are briefly introduced , Then focus on how to build Python development environment , Finally, several common Python Development tools .
Python( pronunciation [ˈpaɪθ ən]) The original meaning is “ Python ”( Here's the thing to note , Python Not named after a python , But on television Monty Python’ s Flying Circus Named after ) , The logo is shown in the picture 1 Shown . Its design philosophy is elegance 、 clear 、 Simple . actually , Python It is also done according to this idea , So now the Internet is streaming “ Life is too short , I use Python” That's what I'm saying . so Python It's simple 、 Fast development speed 、 Save time and energy .Python In itself, not all features and functions are integrated into the language core , It is designed to be extensible . It has a rich and powerful library , Be able to use other languages ( In especial C/C++) The various modules are easily linked together . So , Python Is often referred to as “ glue ” Language . stay 1991 year Python After the first public release of , Python The development of is not outstanding . since 2004 Years later , Python The utilization rate of is increasing linearly . stay 2010 in ,Python gain TIOBE 2010 Annual language Award . until 2020 year , IEEE Spectrum Published in the annual programming language rankings , Python consecutive 4 Won the championship in ,
chart 1 Python sign
Python Since release , Mainly experienced 3 A version , Namely 1994 Published in Python 1.0 edition ( Deprecated ) , 2000 Published in Python 2.0 edition ( Update stopped ) and 2008 Published in Python 3.0 edition ( Now updated to 3.9.x) .
At present , There are two different Python edition : Python 2 And the newer Python 3. Each programming language will continue to develop with the introduction of new concepts and technologies , Python The developers of have been committed to enriching and strengthening its functions . Most of the changes are gradual , You hardly realize , But if your system is installed Python 3, So some use Python 2 The code you write may not work correctly . In this book , I will point out Python 2 and Python 3 Significant differences between , So no matter which one you install Python edition , Can follow the instructions in the book .
If both versions are installed on your system , Please use Python 3; If not installed Python, Please install Python 3; If only installed Python 2, You can also use it directly to write code , But it should be upgraded to Python 3 For good , Because then you can use the latest Python Version of the .
Python It's a powerful , And easy to learn programming language , Therefore, it is widely praised , that Python What can I do ? To sum up, there are the following aspects .
1. Web Development
Use Python A basic application of is to Web Development . At home , Larger use Python Companies that do infrastructure have Douban 、 You know 、 Meituan 、 Are you hungry , And Sohu . Beyond seas , Google It is widely used in its network search system Python, And hired Python The father of .
2. Artificial intelligence
Artificial intelligence ( artificial intelligence) , The abbreviation is AI. Python The reason why it's so hot , Mainly with the help of the development of artificial intelligence . Python Is a scripting language , It is more suitable for artificial intelligence , Because in the field of artificial intelligence Python It has more advantages than other programming languages . The main advantage is , It is simple 、 Fast 、 Scalable ( It is mainly reflected in the application of several excellent artificial intelligence frameworks ) etc. . in addition , Python Machine learning in can realize most of the needs in the field of artificial intelligence .
3. Big data processing
With the rise of big data in recent years , Python Has also been an unprecedented outbreak .Python With the help of a third-party big data processing framework, it is easy to develop a big data processing platform . up to now , Python It's financial analysis 、 One of the most used languages in the field of quantitative trading . for example , Bank of America used Python Language develops new products and infrastructure interfaces , Used to process financial data .
4. Automatic operation and maintenance development
Mastering a development language has become a necessary skill for senior operation and maintenance engineers . Python It's a simple 、 Easy to learn scripting language , It can meet the needs of most automatic operation and maintenance . For operation and maintenance engineers who usually don't develop , Want to learn a development language , Python Is the preferred .
5. Cloud computing
Python It can play a unique role in the field of scientific computing . Python Large data can be calculated through powerful support modules 、 vector analysis 、 Neural network and other aspects to complete the work efficiently , Especially in education and scientific research , Can play a unique advantage . from 1997 Year begins , NASA It's just being used a lot Python Doing all sorts of complicated scientific calculations . Now I finally invented a set of cloud computing software , named OpenStack( Open protocol stack ) , And public release .
6. Game development
adopt Python You can write great game programs , for example , Well known games 《 civilization 6》 Just use Python Compiling . in addition , In the network game development Python There are also many applications . It is embedded in the game as a game script , The advantage of this is that you can take advantage of the high performance of the game engine , It can also benefit from scripted development and other advantages .
7. Web crawler
Web crawler ( Also known as spider) Started and developed in Baidu 、 Google . But with the rise of big data in recent years , Crawler applications have been raised to unprecedented heights . Most analysis and mining companies get data sets from different sources by crawling , Finally, it is used , Then build your own big data integrated platform . In the field of reptiles , Python Almost hegemonic , Through the standard support library it provides, you can basically get the desired data at will .
Simple : Python It's the language of simplicity . Read a good one Python The program feels like reading English . It allows you to focus on solving problems rather than understanding the language itself .
studies of the Book of Changes : Python Extremely easy to use , because Python There are extremely simple documentation .
Easy to read 、 Easy maintenance : Clear and uniform style 、 Force indent
A wide range of uses
Fast : Python The bottom layer is used C Written language , Many standard libraries and third-party libraries are also used C Written , Very fast .
free 、 Open source : Python yes FLOSS( free / Open source software ) One of . Users are free to distribute copies of this software 、 Read its source code 、 Make changes to it 、 Use part of it in new free software .FLOSS It is based on the concept of knowledge sharing by a group .
High level language : use Python Languages are written without considering the low-level details like how to manage the memory your program USES .
Portability : Because of its open source nature ,Python Has been ported to many platforms ( It has been modified to work on different platforms ). These platforms include Linux、Windows、FreeBSD、Macintosh、Solaris、OS/2、Amiga、AROS、AS/400、BeOS、OS/390、z/OS、Palm OS、QNX、VMS、Psion、Acom RISC OS、VxWorks、PlayStation、Sharp Zaurus、Windows CE、PocketPC、Symbian as well as Google be based on linux Developed android platform .
Explanatory : A compiled language such as C or C++ Write the program from the source file ( namely C or C++ Language ) Switch to a language your computer uses ( Binary code , namely 0 and 1). This process passes the compiler and different tags 、 Options complete .
object-oriented : Python Supports both procedural and object-oriented programming . stay “ Process oriented ” The language of , Programs are built from procedures or functions that are simply reusable code . stay “ object-oriented ” The language of , Programs are built from objects that combine data and functionality .
Advanced dynamic programming : although Python May be roughly classified as “ Scripting language ”(script language), But in fact, some large-scale software development plans, such as Zope、Mnet And BitTorrent Google It is also widely used .Python Supporters prefer to call it a high-level dynamic programming language , as a result of “ Scripting language ” Generally refers to a language that only performs simple programming tasks , Such as shellscript、VBScript Programming languages that can only handle simple tasks , Not with Python par .
There are many advantages of doing scientific calculation : Speaking of Scientific Computing , The first thing that will be mentioned may be MATLAB. except MATLAB The tool box can't be replaced by some professional ones ,MATLAB Most of the common functions of can be found in Python Find the corresponding extension library in the world . and MATLAB comparison , use Python Doing scientific calculation has the following advantages :
First ,MATLAB Is a commercial software , And the price is not cheap . and Python Completely free , Many open source scientific computing libraries provide Python Call interface for . Users can install... For free on any computer Python And most of its extension Libraries .
secondly , And MATLAB comparison ,Python It's easier to learn 、 More rigorous programming language . It allows users to write more readable 、 Easy to maintain code .
Last ,MATLAB Mainly focus on engineering and scientific computing . But even in Computing , Also often encounter file management 、 Interface design 、 Network communication and other requirements . and Python It has a rich library of extensions , Can easily complete various advanced tasks , Developers can use Python Various functions required to implement a complete application .
Single line statements and command line output problems : Most of the time, you can't write the program in one line , Such as import sys;for i in sys.path:print i. and perl and awk There's no limit , Can be more convenient in shell Complete the simple procedure , It doesn't need to be like Python equally , You have to write a program to .py file .
Bring confusion to beginners : Unique grammar , This may not be called limitation , However, the way it uses indentation to distinguish sentence relations still brings confusion to many beginners . Even very experienced Python The programmer , You may also fall into a trap .
Slow running speed : Here it means with C and C++ comparison .Python Developers try to avoid immature or unimportant optimizations . Some faster patches for unimportant parts are usually not incorporated into Python Inside . So many people think Python Very slowly . however , According to the law of 28 , Most programs don't require high speed . In some cases with high requirements for running speed ,Python Designers tend to use JIT technology , Or use C/C++ Language rewrite this part of the program . Usable JIT The technology is PyPy.
Originality is not easy. , Please give a compliment to all the big guys passing by