First knowledge of Python

Source: Internet
Author: User
Tags image processing library

Python is an object-oriented, interpreted computer programming language, invented by Dutchman Guido van Rossum in 1989, and the first public release was released in 1991.

Python is purely free software, and the source code and interpreter CPython follow the GPL (GNU general public License) agreement. Python syntax is simple and clear, and one of the features is to force whitespace (white space) to be indented as a statement.

Python has a rich and powerful library. It is often nicknamed the glue language and is able to easily connect a variety of modules made in other languages, especially in C + +. A common application scenario is to use Python to quickly build a prototype of a program (sometimes even the final interface of the program) and then rewrite it in a more appropriate language, such as a graphics rendering module in a 3D game, with a particularly high performance requirement, and can be rewritten in C + + with a specially requested part. It is then encapsulated as an extension class library that Python can call. It is important to note that you may need to consider platform issues when you use the Extended class library, and some may not provide cross-platform implementations.

July 20, IEEE publishes the 2017 programming language leaderboard: Python tops the list.


650) this.width=650; "Src=" https://gss1.bdstatic.com/-vo3dSag_xI4khGkpoWK1HF6hhy/baike/s%3D220/sign= Df945cc2728b4710ca2ffacef3cfc3b2/faedab64034f78f092033e1079310a55b2191ccc.jpg "alt=" logo "style=" float:left; "/>

Since the the early 1990s Python language was born, it has been widely used in the processing of system management tasks and web programming.

The founder of Python is Guido van Rossum. During the Christmas of 1989, in Amsterdam, Guido was determined to develop a new script interpreter as an inheritance of the ABC language in order to get rid of the boredom of Christmas. Python was chosen as the name of the programming language because he was a fan of the comedy community called Monty Python.

ABC is a language of instruction designed by Guido. As far as Guido himself is concerned, the language of ABC is very graceful and powerful and is designed specifically for non-professional programmers. But the ABC language did not succeed, the reason, Guido think is its non-open caused. Guido is determined to avoid this error in Python. At the same time, he wanted to achieve something that had flashed in ABC but had never been realized. In this way, Python was born in the hands of Guido. It can be said that python evolved from ABC and was largely influenced by the Modula-3 (another rather beautiful and powerful language designed for small groups). and a combination of Unix shell and C habits.

Due to the simplicity, legibility and extensibility of the Python language, there is an increasing number of research institutions that use Python to make scientific calculations abroad, and some well-known universities have used Python to teach programming courses. For example, Carnegie Mellon's programming fundamentals, MIT's Introduction to Computer science and programming are taught in the Python language. Many open source scientific computing packages provide Python's calling interface, such as the famous Computer Vision Library OpenCV, the three-dimensional visual library VTK, and the medical image processing library ITK. Python's dedicated Scientific computing expansion library is more, such as the following 3 very classical scientific extension libraries: NumPy, scipy, and matplotlib, which provide Python with fast array processing, numerical operations, and drawing capabilities, respectively. As a result, the Python language and its many expansion libraries make up the development environment ideal for engineering, scientific researchers working with experimental data, charting, and even developing scientific computing applications.

Speaking of scientific calculations, the first thing to be mentioned may be matlab. However, in addition to some of the most professional tools of MATLAB can not be replaced, most of the common functions of MATLAB in the Python world to find the appropriate extension library. Compared with MATLAB, using Python to do scientific calculation has the following advantages:

First of all, Matlab is a commercial software, and expensive. Python is completely free, and many open-source scientific computing libraries provide Python's calling interface. Users can install Python and most of its extension libraries for free on any computer.

Secondly, compared with Matlab, Python is a more easy to learn, more rigorous programming language. It allows users to write code that is easier to read and maintainable.

Finally, MATLAB focuses on engineering and scientific computing. However, even in the field of computing, often encountered in file management, interface design, network communications and other needs. Python, with its extensive library of extensions, can easily perform a variety of high-level tasks, and developers can use Python to implement the full range of functions required by the application.


Python is designed with a clear, consistent style, which makes Python an easy-to-read, easy-to-maintain, widely-used language that is popular with many users.

The overall guiding ideology of designer development is that, for a particular problem, there is only one best way to solve it. This is stated in the Python motto (known as the Zen of Python) written by Tim Peters: there should be one--and preferably only one--obvious the-do it. This is exactly the opposite of the central idea of the Perl language (another feature-like advanced Dynamic language), TMTOWTDI (there's more Than one-way-to-do It).

Python authors intentionally design restrictive grammars that make bad programming habits (such as the next line of an if statement not indented to the right) fail to compile. One of the most important is the Python indentation rules.

The difference between one and most other languages, such as C, is that the bounds of a module are determined entirely by the position of the first character of each line in that line (and the C language is explicitly defined by a pair of curly braces {} to define the bounds of the module, which has no relation to the position of the character). This has been controversial. Since the birth of a language such as C, the grammatical meaning of the language is separated from the arrangement of the characters, which was once thought to be the progress of a programming language. It is undeniable, however, that Python does make the program clearer and more beautiful by forcing programmers to indent, including if,for and function definitions, where all the modules need to be used.


When Python executes, the source code in the. py file is first compiled into Python's byte code (bytecode), which is then executed by Python virtual machine (python vm) to execute the compiled byte code. The basic idea of this mechanism is with Java,. NET is consistent. However, Python virtual machine differs from Java or. NET virtual machine in that Python's virtual machine is a more advanced virtual machine. The high-level here is not in the usual sense, not that Python's virtual machine is more powerful than Java or. NET, but rather that Python's virtual machines are farther away from the real thing than Java or. Net. Or so, Python's virtual machine is a higher-level, more abstract virtual machine.

A C-based Python-compiled bytecode file, usually the. pyc format.

In addition, Python can also run in interactive mode, such as the main operating system Unix/linux, MAC, Windows can directly run the Python interactive environment directly in command mode. The direct release of the operation instructions allows for interactive operation.


Application:

System Programming : Provide API (Application programming Interface application programming Interface), can facilitate system maintenance and management, Linux under one of the iconic language, is the ideal programming tool for many system administrators.

graphics Processing: pil, Tkinter and other graphics library support, can be easily graphics processing.

Mathematical Processing: The numpy extension provides a large number of interfaces to many standard math libraries.

Text Processing:The RE module provided by Python supports regular expressions, and it also provides sgml,xml analysis modules, and many programmers use Python for the development of XML programs.

Database Programming : Programmers can communicate with Microsoft SQL Server,oracle,sybase,db2,mysql, SQLite, and other databases through modules that follow the Python DB-API (database application programming Interface) specification. Python comes with a gadfly module that provides a complete SQL environment.

Network Programming : Provides a wide range of modules to support sockets programming, enabling fast and easy development of distributed applications. Many large-scale software development programs such as Zope,mnet and BitTorrent. It is widely used by Google.

Web Programming : The development language of the application, supporting the latest XML technology.

Multimedia Applications: Python's Pyopengl module encapsulates the "OpenGL application Programming Interface" for two-and three-dimensional image processing. The Pygame module can be used to write game software.

Pymo Engine: Pymo is all called Python memories off and is a AVG game engine running on Symbian S60v3,symbian3,s60v5, SYMBIAN3, and Android systems. It is named Pymo because it is developed based on the python2.0 platform and is applicable to the AVG game that creates the memory of autumn (memories off) style.

hacking Programming:python has a hack library with built-in functions that you are familiar with or unfamiliar with, but lack a sense of accomplishment.

Write simple crawlers in Python:

First of all, to get the corresponding HTML source code by URLLIB2 this module.

1234 importurllib2  #调用urllib2  url=‘http://www.baidu.com/s?wd=cloga‘ #把等号右边的网址赋值给urlhtml=urllib2.urlopen(url).read()   #html随意取名 等号后面的动作是打开源代码页面,并阅读print html #打印

Through the above three sentences can be the source code of the URL exists in the content variable, its type is character type.

The next step is to extract the content we need from this stack of HTML sources. Use Chrome to see the code for the corresponding content (you can also use Firefox's Firebug).

You can see that the information for the URL is stored in the span tag, and the information you want to get it can be used in regular style.


This article is from the "Geekboss Institute" blog, please make sure to keep this source http://geekboss.blog.51cto.com/13147034/1954716

First knowledge of Python

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.