Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

What are the knowledge points that you must know to get started with Python?

2025-01-19 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/03 Report--

This article mainly introduces the introduction of Python must know what the knowledge points, the article is very detailed, has a certain reference value, interested friends must read it!

Introduction to Python

Python is a high-level scripting language that combines interpretation, compilation, interactivity and object-oriented.

The design of Python is highly readable. Compared with other languages, it often uses English keywords and some punctuation marks. It has more distinctive grammatical structures than other languages.

Python is an interpreted language: this means that there is no compilation in the development process. Similar to PHP and Perl languages.

Python is an interactive language: this means that you can write your program interactively at a Python prompt.

Python is an object-oriented language: this means that Python supports object-oriented styles or code-encapsulated programming techniques.

Python is a language for beginners: Python is a great language for beginner programmers, supporting a wide range of application development, from simple word processing to WWW browsers to games.

Development history of Python

Python was designed by Guido van Rossum at the National Institute of Mathematics and computer Science in the Netherlands in the late 1980s and early 1990s.

Python itself has evolved from many other languages, including ABC, Modula-3, C, C++, Algol-68, SmallTalk, Unix shell, and other scripting languages.

Like the Perl language, Python source code follows the GPL (GNU General Public License) protocol.

Now that Python is maintained by a core development team, Guido van Rossum still plays a vital role in guiding its progress.

Characteristics of Python

1. Easy to learn: Python has relatively few keywords, a simple structure, and a well-defined syntax, making it easier to learn.

two。 Easy to read: the definition of Python code is clearer.

3. Easy to maintain: the success of Python is that its source code is fairly easy to maintain.

4. A wide range of standard libraries: one of the biggest advantages of Python is its rich libraries, cross-platform, and good compatibility between UNIX,Windows and Macintosh.

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

6. Portable: based on its open source nature, Python has been ported (that is, to make it work) to many platforms.

7. Extensible: if you need a critical piece of code that runs fast, or if you want to write algorithms that you don't want to open up, you can use C or C++ to complete that part of the program and call it from your Python program.

8. Database: Python provides interfaces to all major commercial databases.

9.GUI programming: Python supports GUI to create and port to many system calls.

10. Embeddable: you can embed Python into the CumberCraft + program to give users of your program the ability to "scripting".

1. Which application scenarios does Python apply to?

There is no fixed answer to this. Many people say that Python is not suitable for developing GUI programs, but Python's own IDE--IDEL and third-party IDE--Eric are written by Python.

At present, more people are using it to write Web, using frameworks such as Django and web.py, and so is Flask.

There is also a situation where you use Python as glue and combine with various languages to complete a software function. Pay attention to the observation that you may find that there will be Python when installing some software.

Personally, I have simulated port forwarding and DNS services with Python, so it really depends on how it is used, not how it can be used.

In addition, big data analysis of Python is also more appropriate, from loading to analysis, and then to saving the results, Python has a complete set of modules to deal with.

2. Is Python competent for big data?

Python is very suitable for big data-related analysis, the built-in C compilation module can cope with common operations, some extreme algorithms are recommended to use C to rewrite related modules.

The characteristics of Python itself are more efficient development and simple maintenance, speed to C, more problems actually come from the code writers do not have better use, rather than inefficient enough. For example, sorting, Python originally has a very efficient built-in C compilation module, but has to write its own algorithm, such a result is not slow is strange.

In addition, it depends on whether the demand is CPU-intensive or IO-intensive. If it is CPU-intensive, it is suggested that this part of the operation is implemented by C, and the efficiency of IO-intensive will not change much because of Python.

C is efficient, but the framework is also hard to build, so it's better to combine it, and that's why Python is called glue language.

3. Can Python completely replace Shell?

Absolutely, the function Python of Shell can be realized, and the amount of code is less, the structure is better, and the readability is better, while the function Shell that Python can achieve may not be possible, such as Socket module for network communication, Django framework for WEB, psutil module for performance collection, etc., and Shell is more dependent on operating system commands, Python can be avoided to a greater extent.

In a Shell IDE is a big problem, although Python's native IDE is not good, but the third-party IDE is still very powerful, although not comparable to Microsoft's Virtual Studio, but also can fully meet the development needs of Python.

Let's talk about the efficiency of Python. Python supports multi-process, multi-threading and co-programming (one level smaller than threads), and the degree of program concurrency is above Shell. The core modules of Python are basically implemented in C, so it is more efficient. If necessary, it is possible to rewrite Python modules that need to be implemented in Python in C to improve efficiency, or you can directly use C Python, a Python interpreter that is directly implemented in C.

4. Can Python access common databases?

Yes, Python can access various common databases, such as Oracle, MySQL, Vertica, SQLServer, etc. You can load the corresponding modules. The list of modules is as follows:

Oracle:cx_Oracle

MySQL:MySQLdb

Is Python development process-oriented, function-oriented or object-oriented?

Although Python is an interpretive language, it has been an object-oriented language since the beginning of its design. For Python, everything is an object. Because of this, it is easy to create a class and object in Python. Of course, if you are accustomed to process-oriented or function-oriented writing, Python does not impose rigid restrictions.

Object-oriented features of Python are as follows:

Encapsulation

The term Object in object-oriented programming can basically be seen as data (properties) and a collection of methods that can access and manipulate that data. In the traditional sense, "program = data structure + algorithm" is encapsulated "masked" and simplified to "program = object + message". An object is an instance of a class, and the abstraction of the class needs to be encapsulated. Encapsulation allows the caller to use it without caring about how the object is built.

Inherit

Class inheritance:

Inheritance gives a direct impression that it is an act of reusing code. Inheritance can be understood as establishing a special class object based on an ordinary class, and the relationship between the subclass and the parent class it inherits is IS-A.

Multiple inheritance:

Unlike Centro Interface Python, it supports multiple class inheritance (C # can inherit from multiple Python, but from at most one class). The multiple inheritance mechanism sometimes works well, but it tends to complicate things.

Polymorphisms

Polymorphism means that the same operations can be used on different objects, but they may present results in multiple forms. In Python, polymorphism is used when you don't know what type an object is, but you need it to do something. The method is polymorphic, and so are the operators.

6. How to master Python quickly?

Reading official documents can meet daily needs, official documents have Chinese translation, more convenient to learn. But these are the basic grammar and common modules, Python learning is important to the module, fast and efficient development depends on the application of the module, standing on the shoulders of predecessors will save much time and effort.

But the most important thing to learn Python is the learning module, not the grammar itself. The grammar of Python is very simple, as long as the university has taken C or data structure courses, even people who have not learned it at all can easily master it. Mastering the syntax has been able to achieve the function of Shell, but it is essential to improve the learning of modules, such as the ones often used by operators:

Psutil: get performance information

Socket: basic network communication

IPy:IP address related processing

Dnsptyhon: domain name related processing

Difflib: file comparison

Pexpect: screen information acquisition, often used for automation

Paramiko:SSH client

XlsxWriter:Excel related processing

There are many other functional modules, and new modules, frameworks and components are constantly generated every day, such as PythonJS for bridging with Java, and even Python can write Map and Reduce.

7. Does Python have a dedicated IDE tool?

Yes, IDEL uses Python to implement Python's IDE tool, but to be honest, the function is really not very good. My personal IDE is as follows:

PyCharm

PyCharm is a Python IDE developed by JetBrains. PyCharm is used for general IDE functions, such as debugging, syntax highlighting, Project management, code hopping, smart hints, automatic completion, unit testing, version control. In addition, PyCharm also provides some good features for Django development, while supporting Google App Engine, and even cooler, PyCharm supports IronPython!

Wing IDE

Wingware's Python IDE is compatible with Python 2.x and 3.x and can be used in combination with Django,matplotlib,Zope, Plone,App Engine,PyQt,PySide,wxPython,PyGTK,Tkinter,mod_wsgi,pygame,Maya,MotionBuilder,NUKE,Blender and other Python frameworks. Wing supports test-driven development and integrates unit testing, nose and Django framework execution and debugging functions. Wing IDE starts and runs very fast, supporting Windows,Linux,OS X and Python versi.

NotePad++

Simple and convenient, but only suitable for temporary changes.

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

8. What are the common methods of using Python to realize system automatic monitoring?

To be exact, what modules should there be? health monitoring must have psutil to monitor performance, and it will also use communication Socket, login Paramiko, telnetlib,ftp ftplib.

The basic principle is to collect data-- local processing data-- transfer data. If you do it perfectly, you can do a presentation of data, or you can send the data to open source tools such as Zabbix.

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

9. On which platforms can Python run? How is cross-platform?

Support common mainstream platforms, such as AIX, HPUX, Solaris, Linux, Windows, etc. Unix and Linux platforms except Windows are equipped with native Python, but the version is generally lower. With regard to cross-platform and his cross-platform language, it should be noted that some individual modules are unique to a single platform, the overall cross-platform is still very good, and there is no need to write multiple sets of code to adapt to multiple platforms.

But this is not to say that there are no restrictions: first, the intermediate files .py and .pyc and .pyo of the same version are cross-platform; second, PC and mobile terminals, such as mobile phones and Pad, cannot cross platforms (see the next article); finally, they cannot cross processor architectures, such as Intel and ARM,64 bits and 32 bits.

10. How to use Python to improve development efficiency?

Because many of the underlying things in Python do not need to be written by yourself, the module resources are rich, and the efficiency of development will certainly be improved if used properly, and various frameworks also provide the basis for rapid development.

11. How fast does Python run?

Java is usually faster than Python. Except that Python calls the C extension (or you can use CPython directly).

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

If you develop a system that finds performance bottlenecks, the most efficient thing to do is to find the block of code in question and replace the function or module with some code in a faster language such as C or C++, rather than rewriting the entire system in C or C++, because for most of the code, the speed of the language doesn't matter.

The above is all the contents of this article "what are the knowledge points you must know in the introduction to Python?" Thank you for your reading! Hope to share the content to help you, more related knowledge, welcome to follow the industry information channel!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report