Quick Python programming entry, to lay a solid foundation of knowledge must know 11 points!

Python programming language known as efficient in the world, also referred to as a "glue language", that why it can be so popular here we are concerned that Python started to learn the necessary knowledge 11 points, that is, it why be so popular.

Introduction to Python

Python is a combination of interpretive compiler, interactive object-oriented scripting language and high-level.

Python's design highly readable, compared to other languages ​​often use English keywords, some of the punctuation other languages, it has more features than any other language grammar structure.

Python is an interpreted language: This means that the development process does not compile this link. Like PHP and Perl languages.

Python is an interactive language: This means that you can in a Python prompt to interact directly write your program.

Python is an object-oriented language: This means that Python supports object-oriented style of programming or code encapsulated in objects.

Python is a beginner's language: Python for junior programmers, is a great language, it supports a wide range of application development, from simple word processing to the WWW browser and then to the game.

 

 

Python Development History

Python by Guido van Rossum in the late eighties and early nineties, the Dutch National Institute for Mathematics and Computer Science designed.

Python itself is made of many other languages ​​evolved, including ABC, Modula-3, C, C ++, Algol-68, SmallTalk, Unix shell and other scripting languages, and so on.

Like Perl languages, Python source code is likewise follow GPL (GNU General Public License) protocol.

Python is now maintained by a core development team, Guido van Rossum continues to occupy a crucial role in guiding their progress.

Python Features

1. Easy to learn: Python has relatively few keywords, simple structure, grammar and a well-defined learning curve easier.

2. Easy to read: Python code defines more clearly.

3. Easy to maintain: Python's success lies in its source code is fairly easy to maintain.

4. A wide range of standard library: One of the biggest advantages of Python's library is rich, cross-platform, in UNIX, Windows and Macintosh compatible well.

5. Interactive mode: interactive mode, you can enter to execute code from the terminal and get the results of the language, interactive testing and debugging code snippets.

6. Portable: based on the characteristics of its open source, Python has been ported (ie to make it work) to many platforms.

7. Scalable: If you need to run some fast key code, or want to write some algorithms do not want to open, you can use C or C ++ to complete that part of the program, and then call from your Python program.

8. Database: Python provides an interface to all major commercial databases.

9.GUI Programming: Python GUI support can be created and ported to many system calls.

10. Can Embed: You can embed Python to C / C ++ program that allows users the ability to get your program "script" of.

1, Python application scenarios which apply to?

There is no fixed answer to this, a lot of people say that Python is not suitable for the development of GUI programs, but their Python IDE - IDEL and third-party IDE - Eric is written in Python.

Are seeing more people are used to write Web, such as using Django, web.py framework, Flask is not mistaken.

There is also a case with more, with Python as glue, combined with a variety of languages, have completed a software function, observe maybe you'll find some software when installing Python will figure.

Personally, I also had to get Python analog port forwarding and DNS services, so there really is to see what really use, rather than how to use energy.

Also big data analytics Python is more appropriate, from into the analysis, and then save the results and so on, there is a set of Python modules deal with.


 

 

2, Python capable big data?

Python is suitable for bigger and analyze data related to the built-in C compiler module can deal with common operation, individual extreme algorithm C is recommended to rewrite the relevant module.

Features Python itself is more efficient development and simple maintenance, speed, go to C, more problems actually comes from people who do not write code to better use, rather than efficiency is not high enough. Such as sorting, Python has had a very efficient built-in C compiler modules, but have to write their own algorithms, such results are not surprising slow.

Also it depends on demand is CPU-intensive, or IO-intensive, CPU-intensive if it is recommended that this part of the operation is implemented by C, IO-intensive because of Python and efficiency will not have changed much.

C is a high efficiency, but also take up strenuous framework, they still come in conjunction with, and therefore, Python is called glue language.

3, Python if you can completely replace Shell?

Can, Python Shell function can achieve, and less code, better structure, better readability, and Python Shell function can not necessarily be achieved, such as operation and maintenance networks will be used for Socket module communications for the WEB Django framework for performance psutil acquisition module, and the Shell command strong dependence of the operating system, Python can avoid a greater extent.

IDE in a Shell is a big problem, although native Python IDE is not very good, but the third-party IDE or function is very powerful, and although it is not comparable to Microsoft's Virtual Studio, but it is also able to fully meet the development needs of Python of.

Besides the lower efficiency of Python, Python supports multi-process, multi-thread and Association process (thread smaller than a), the program is on the degree of concurrency of Shell. Python core modules are basically implemented in C, and therefore more efficient. If necessary, may also need to be implemented in Python C Python module rewritten to improve efficiency, of course, can be directly used Python C, with a direct fully implemented in Python interpreter C.

4, Python can access a common database?

Can, Python can access a variety of common databases, such as Oracle, MySQL, Vertica, SQLServer, etc., you can load the appropriate module list module as follows:

Oracle:cx_Oracle

MySQL:MySQLdb

5, Python development-oriented procedures, functions or objects?

Although Python is an interpreted language, but from the beginning of the design already is an object-oriented language, Python is for everything is an object. Because of this, it creates a class and objects in Python is easy, of course, if the habit of writing for the procedure or function is also possible, Python does not do hard limit.

Python object-oriented features are as follows:

Package

The term Object Oriented (Object) target program can be regarded as substantially designed data (characteristics) and can be accessed by a series of operation of the data collection method thereof. "Algorithms + data structures = programs" in the traditional meaning of encapsulation is "masked" and reduced to "Program + = Object message." Objects are instances of classes, an abstract class is required encapsulated. Package allows the caller does not care how the object is constructed and direct use.

inherit

Class inheritance:

Inheritance gives the impression that this is a direct reuse the code of conduct. Inheritance can be understood as it is a normal class based on the establishment of a special class of objects, and its subclasses inherit parent's relationship IS-A.

Multiple inheritance:

Different from C #, Python supports multiple inheritance class (C # can inherit from multiple Interface, but most inherited from a class). Multiple inheritance is sometimes useful, but it is easy to make things complicated.

Polymorphism

Polymorphism means you can use the same operation on different objects, but they may be in a variety of forms showing results. In Python, any objects in the end do not know what type, but the object needs to do something that they will use polymorphism. The method is polymorphic, the operator is polymorphic.

6, how to quickly grasp Python?

Read the official documentation to meet the daily needs, there are Chinese translations of official documents, easier to learn. But the syntax and common modules which are based, Python is learning important module, fast, efficient development is dependent on the application module, saving more time standing on the shoulders of the Province predecessors.

Learning Python but the most important thing is learning modules, rather than the syntax itself, Python's syntax is very simple, as long as the university learned C or data structure courses, or even people who never studied also can easily grasp. Master function syntax has been achieved Shell, but in order to improve the learning module is essential, such as operation and maintenance personnel often use are:

psutil: to obtain performance information

socket: Basic Network Communications

IPy: IP address associated processing

dnsptyhon: domain-related processing

difflib: file comparison

pexpect: screen access to information, commonly used in automation

paramiko: SSH Client

XlsxWriter: Excel related processing

There are many, many other functional modules, but also constantly every day new modules, frames, components produced, such as for Java to do with bridging PythonJS, even Python can also write Map and Reduce.

7, Python Is there a dedicated IDE tools?

There, Python IDE tools IDEL implemented in Python, but to be honest, is not ye really function. My personal favorite IDE as follows:

PyCharm

PyCharm is JetBrains development Python IDE. PyCharm for general IDE with features such as, debugging, syntax highlighting, Project management, code branches, IntelliSense, auto-complete, unit testing, version control ...... In addition, PyCharm also offers some nice features for Django development, and support Google App Engine, cooler is that, PyCharm support IronPython!

Wing IDE

Wingware the Python IDE compatible Python 2.x and 3.x, may be combined Django, matplotlib, Zope, Plone, App Engine, PyQt, PySide, wxPython, PyGTK, Tkinter, mod_wsgi, pygame, Maya, MotionBuilder, NUKE, Blender and other Python framework. Wing support for test-driven development, integration, implementation and debugging unit tests, nose and Django framework. Wing IDE up and running speed is very fast, supports Windows, Linux, OS X and Python versi.

NotePad++

Simple, convenient, but only for a temporary change.

Others include: Eclipse withPyDev, Sublime Text, Komodo Edit, Pyer, The Eric Python IDE, Interactive Editor for Python

8, which use a common method to achieve Python automated monitoring system have?

Precisely what should be the module, be sure to have psutil health monitoring to monitor the performance, it will be used in Socket Communications, landing Paramiko, telnetlib, ftp of ftplib.

The basic principle is to collect data - data locally - data transmission, if you can do and then make a more complete presentation of data, it can send data to Zabbix and other open source tools.

Individuals also use an open source network monitoring spying, and more than a specified number of times is automatically blocked.

9, Python can run on those platforms? Cross-platform how?

Supports all the popular platforms, such as AIX, HPUX, Solaris, Linux, Windows, etc., in addition to Windows common Unix, Linux platforms with a native Python, but generally lower version. About cross-platform and cross-platform language, like him, should pay attention to some individual modules are specific to a single platform, cross-platform as a whole is still very good, do not have to write code to adapt to multiple sets of multi-platform.

But this is not to say that no restrictions are: First, the same version of the intermediate files .py and .pyc and .pyo is cross-platform; secondly, PC and mobile terminals, such as: cell phone, Pad can not be cross-platform (see below a reason ); Finally, not cross-processor architecture, such as: Intel and ARM, 64 and 32-bit.

10, how to use Python to improve development efficiency?

Python because many of the underlying things do not write their own rich resources module, used properly will certainly improve the development efficiency, but also various frameworks provide the foundation for rapid development.

11, how to speed Python?

Java is usually speeds faster than Python. Python C extensions except call (can be directly used CPython).

Python is too slow for criticism, Python language author Guido van Rossum said:

If you develop a system performance bottleneck found, usually the most efficient approach is to find the code block the problem, with faster language such as C or C ++ to write some code or replace the function of the module, rather than C or C ++ rewrite the whole system, because most of the code, the speed of the language is irrelevant.

Learning is one of the greatest accomplishment through learning can not only enhance their own realm, but also a wealth of knowledge, to lay the foundation for future employment, learning Python is a good opportunity to develop their own, the time has come, after all, artificial intelligence, artificial as Python the main force of the smart times is very promising, not decadent dreams, sweat all the way there. Come on!

Guess you like

Origin www.cnblogs.com/guran0823/p/12394653.html