Self-taught python--------Introduction to python

Python
Python[1] (British pronunciation: /ˈpaɪθən/ American pronunciation: /ˈpaɪθɑːn/), is an object-oriented interpreted computer programming language, invented by the Dutch Guido van Rossum in 1989, the first public release Released in 1991.
Python is pure free software. The source code and interpreter CPython follow the GPL (GNU General Public License) agreement [2].
Python syntax is concise and clear, and one of its features is to force the use of Tab as a statement indentation.
Python has a rich and powerful library. It is often nicknamed the glue language, which can easily connect various modules made in other languages ​​(especially C/C++). A common application situation is to use Python to quickly generate the prototype of the program (sometimes even the final interface of the program), and then rewrite the parts with special requirements in [3] in a more suitable language, such as graphics in 3D games The rendering module, which requires particularly high performance, can be rewritten in C/C++, and then encapsulated as an extended library that can be called by Python. It should be noted that you may need to consider platform issues when you use extended class libraries, and some may not provide cross-platform implementation.
 
Application field
  system programming: Provide API (Application Programming Interface), which can facilitate system maintenance and management. One of the iconic languages ​​under Linux is an ideal programming tool for many system administrators [7].
Graphics processing: It is supported by graphics libraries such as PIL and Tkinter, which can facilitate graphics processing.
Mathematics processing: The NumPy extension provides a large number of interfaces with many standard math libraries.
Text processing: The re module provided by python can support regular expressions, as well as SGML and XML analysis modules. Many programmers use python to develop XML programs.
Database programming: Programmers can communicate with databases such as Microsoft SQL Server, Oracle, Sybase, DB2, MySQL, and SQLite through modules that follow the Python DB-API (Database Application Programming Interface) specification. Python comes with a Gadfly module, which provides a complete SQL environment.
Network programming: Provides a wealth of modules to support sockets programming, enabling easy and rapid development of distributed applications. Many large-scale software development projects such as Zope, Mnet and BitTorrent. Google are using it extensively.
Web programming: application development language, supporting the latest XML technology.
Multimedia applications: Python's PyOpenGL module encapsulates the "OpenGL application programming interface", which can perform 2D and 3D image processing. The PyGame module can be used to write game software.
Pymo engine: PYMO is called python memories off. It is an AVG game engine running on Symbian S60V3, Symbian3, S60V5, Symbian3, and Android systems. Because it is developed based on the python2.0 platform and is suitable for creating memories off-style AVG games, it is named PYMO.
Hacker programming: Python has a hack library with built-in functions that you are familiar with or unfamiliar with, but it lacks a sense of accomplishment.
Writing a simple crawler in Python
First of all, the corresponding HTML source code must be obtained through the urllib2 Module.
1234import urllib2 #Call urllib2 url='http://www.baidu.com/s?wd=cloga' # Assign the URL on the right side of the equal sign to urlhtml=urllib2.urlopen(url).read() #html name it at will The action after the equal sign is to open the source code page, and read print html
#print Through the above three sentences, the source code of the URL can be stored in the content variable, and its type is character type.
The next step is to extract what we need from this pile of HTML source code. Use Chrome to view the corresponding content code (you can also use Firefox's Firebug).
You can see that the url information is stored in the span tag, and you can use regular expressions to get the information.
Use python to automate testing, automate the operation and maintenance of big data analysis, etc.
 
The interpreter
Python is a cross-platform scripting language. Python stipulates a Python grammar rule. The interpreter that implements the Python grammar becomes the interpreter of Python.
CPython (ClassicPython, which is the original Python implementation, is called CPython when it needs to be distinguished from other implementations; or interpreted as Python implemented in C language). This is the most commonly used version of Python.
Jython (formerly known as JPython; Python implemented in Java language, now officially released). Jython can directly call various function libraries of Java.
PyPy (Python written in Python language)
IronPython (Python implementation for .NET and ECMA CLI). IronPython can directly call various function libraries of the .net platform. You can compile Python programs into .net programs.
ZhPy (Zhou Mang) (Python language
 
that supports the use of Traditional/Simplified Chinese sentences to write programs. The advantages are
 
simple-Python is a language that represents the idea of ​​simplicity. Reading a good Python program feels like reading English, although The English requirements are very strict! The pseudo-code nature of Python is one of its greatest advantages. It allows you to focus on solving problems instead of understanding the language itself.
Easy to learn-just as you are about to see Similarly, Python is extremely easy to learn. As mentioned earlier, Python has an extremely simple syntax.
Free and open source-Python is one of FLOSS (free/open source software). Simply put, you can freely distribute this software Copy, read its source code, make changes to it, and use part of it in new free software. FLOSS is based on the concept of sharing knowledge by a group. This is one of the reasons why Python is so good-it is Created by a group of people who want to see a better Python and often improve it.
High-level language - When you write programs in Python, you don’t need to think about things like how to manage the memory used by your program. Low-level details.
Portability - Because of its open source nature, Python has been ported to many platforms (it has been modified to work on different platforms). If you are careful to avoid using system-dependent features, then All your Python programs can run on any of the following platforms without modification. 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 and even PocketPC, Symbian and Google's Android platform based on Linux!
Explanatory-This point requires some explanation. A program written in a compiled language such as C or C++ can be converted from a source file (ie C or C++ language) to a language used by your computer (binary code, ie 0 and 1). This process is completed by the compiler and different flags and options. When you run your program, the linker/reloader software copies your program from the hard disk to the memory and runs it. And the program written in Python language does not need to be compiled into binary code. You can run the program directly from the source code. Inside the computer, the Python interpreter converts the source code into an intermediate form called bytecode, and then translates it into the machine language used by the computer and runs it. In fact, since you no longer need to worry about how to compile programs, how to ensure that the correct libraries are linked and reproduced, etc., all of this makes using Python easier. Since you only need to copy your Python program to another computer, it will work, which also makes your Python program more portable.
Object-oriented-Python supports both process-oriented programming and object-oriented programming. In "procedure-oriented" languages, programs are constructed from procedures or functions that are simply reusable code. In an "object-oriented" language, programs are constructed from objects composed of data and functions. Compared with other major languages ​​such as C++ and Java, Python implements object-oriented programming in a very powerful and simple way.
Scalability-If you need a piece of your key code to run faster or if you want certain algorithms not to be public, you can write part of your program in C or C++, and then use them in your Python program.
Abundant libraries-The Python standard library is indeed huge. It can help you deal with various tasks, including regular expressions, document generation, unit testing, threads, databases, web browsers, CGI, FTP, email, XML, XML-RPC, HTML, WAV files, password systems, GUI (Graphical user interface), Tk and other system-related operations. Remember, as long as Python is installed, all these features are available. This is called the "full-featured" philosophy of Python. In addition to the standard library, there are many other high-quality libraries, such as wxPython, Twisted, and Python image libraries.
Standard code-Python uses forced indentation to make the code extremely readable.

Disadvantages
1. Running speed, if there is a speed requirement, use C++ to rewrite the key part.
2. The domestic market is relatively small (the domestic development is mainly based on python, and currently there are only some web2.0 companies). However, as time goes by, many domestic software companies, especially game companies, have also begun to use it on a large scale.
3. The lack of Chinese materials (there are only a handful of good python Chinese materials). Thanks to the community, several excellent textbooks have been translated, but there are many entry-level textbooks, and the advanced content can only be read in English.
4. There are too many architecture choices (there is no official .net architecture like C#, nor is there a relatively concentrated architecture development like ruby ​​due to its short history. The Ruby on Rails architecture is invincible for the development of small and medium-sized web programs). But this also shows from another side that python is better, attracts more talents, and projects.

Guess you like

Origin blog.csdn.net/weixin_47580822/article/details/112862576