1.python Introduction: What kind of language is Python, Introduction to the basic features of Python
Python is a powerful, object-oriented dynamic, strong type, interpreted high-level programming language, is also a glue language, it has a cross-platform, robust, easy to learn and easy to use and other characteristics.
There are several key words in the above sentence: powerful object-oriented dynamic Strong-type interpretation advanced programming language Glue language Cross-platform robustness easy to learn and easy to use, below I will explain these nouns in one step:
(1) powerful : Python has a wide range of uses, as I know of Python applications---- Web development, crawler, data processing, cloud computing, artificial intelligence (AI), system operations, finance, graphical interface development, etc.
Web Development :
Python has the following Web framework: Django, Flask, Tnornado.
Django is a widely used enterprise-class web framework that uses Django itself to develop some very complete web applications, and because of this, Django has a pivotal place in enterprise-level Web development.
Flask is a relatively new framework that emerged in the 2010, flask major applications and micro-projects, while it is extensible, allowing developers to freely choose database storage data, flask is a micro-framework for simple requirements and small applications.
There is a significant difference between the Tornado and the current mainstream WEB server framework, including most Python frameworks: It's a non-blocking server and it's pretty fast. With its non-blocking approach and its use of epoll, Tornado can handle thousands of connections per second, so Tornado is an ideal framework for real-time WEB services. Tornado is often used as an interface service framework for large sites, rather than as a full-scale web site like Django.
crawler :
Crawler (also known as web crawler, Web spider, Network robot), is a certain rules, automatically crawl the site information program or script. Python has specialized modules to access the Internet to send requests, such as the most basic urllib modules, as well as some third-party libraries such as the requests module. Python also has third-party modules that can parse the source code of the Web page, such as the BeautifulSoup library.
Data processing:
Python has some modules for data processing, such as NumPy, Pandas, and Matplotlib.
NumPy is an open-source numerical extension of Python. This tool can be used to store and manipulate large matrices, which is much more efficient than Python's own nested list (nested list structure) structure. Pandas is a numpy-based tool that was created to solve the data analysis task.
Pandas incorporates a number of libraries and a number of standard data models, providing the tools needed to efficiently manipulate large datasets. Pandas provides a number of functions and methods that enable us to process data quickly and easily, and is one of the important factors that make Python a powerful and efficient data analysis environment.
Matplotlib is a Python 2D drawing library that generates publishing quality-level graphics in a variety of hard-copy formats and cross-platform interactive environments to visualize data.
Cloud computing :
Python is also used in this area, and is a high-profile, well-known OpenStack developed by Python, a free software and open source project that was developed and initiated by NASA and Rackspace in collaboration with Apache licensing. And OpenStack is an open-source cloud management platform project that combines several key components to do the job. OpenStack supports almost all types of cloud environments, and the project goal is to deliver a simple, massively scalable, rich, standard, unified cloud management platform.
Artificial Intelligence (AI) :
Python has a lot of third-party modules for artificial intelligence, such as NumPy, scipy do numerical calculations, Sklearn do machine learning, pybrain do neural networks, matplotlib data visualization.
system operation and maintenance :
There is no doubt that Python is a programming language that the industry's operations engineers must have.
Finance :
Quantitative trading, financial analysis, in the field of financial engineering, Python is not only used, and used the most, but also the importance of increasing year by year.
Reason: As a dynamic language Python, the language structure is clear and simple, the library is rich, mature and stable, scientific calculation and statistical analysis are very good, production efficiency is much higher than c,c++,java, especially good at strategy backtesting.
graphical interface Development :
Python supports a third-party library of multiple graphical interfaces, including: PyQT, Wxpython,tkinter, and more.
Tkinter is a python-brought library that can be used directly with Tkinter without installing any packages.
QT is a C + + written cross-platform development framework, QT has existed for a long time, was a Nokia company, as a very comprehensive tool code base and API, is widely used in many industries, covering a number of platforms including mobile. PYQT is a toolkit for creating GUI applications. It is a successful fusion of Python language and QT libraries. The QT Library is one of the most powerful libraries available.
Wxpython is a good set of GUI graphics libraries for the Python language. It allows Python programmers to easily create complete GUI user interfaces with full function keys. Wxpython is provided to the user as an excellent cross-platform GUI library wxwidgets python package and Python module.
(2) Object-oriented: Object-oriented is a kind of programming thinking, is also a software development method, is the development of computer programming technology to a certain stage of the product.
Object-oriented is a kind of method to understand and abstract the real world, it is the product of the development of computer programming technology to a certain stage, also is a kind of programming thinking. Object-oriented is to regard objective things as objects with attributes and behaviors.
A class is formed by the abstraction of objective things to find common attributes (static attributes) and behaviors (dynamic characteristics) of the same class of objects. Each object has its own data, operations, functions, and purposes. Through the inheritance and derivation of classes, polymorphism and other techniques
To improve the reusability of software code. Object-oriented programming thinking is closer to human thinking activities, according to people's understanding of the objective world system thinking mode, the use of object-based (entity) concept to establish a model, simulation of the objective
, the method of analyzing, designing and implementing software, through the object-oriented concept, makes the computer software system can correspond with the system one by one in the real world.
(3) dynamic : Static and dynamic correspondence, namely static type language, dynamic type language, is the period of checking the type.
Statically typed languages are languages that can be determined at compile-time variable data types, and data type checks for static type languages are judged before they run (such as the compile phase), such as C, C + +, C #, and Java, which are statically typed languages. While dynamic type languages do not require a static type language to require that a data type be declared before a variable is used, a data type check of a dynamic type language type is done at run time, and the type declaration is not required before the variable is used, and the type of the variable is usually the type of the value being assigned.
(4) strongly typed : strongly typed and weakly typed refer to the data type definition of the programming language.
Strongly typed definition language: A language that enforces the definition of a data type. In other words, once a variable is assigned a data type, it is always the data type if it is not cast. For example: If you define an integer variable A, the program simply cannot treat a as a string type. A strongly typed definition language is a type-safe language.
Weak type definition language: A language in which data types can be ignored. In contrast to strongly typed definition languages, a variable can assign values of different data types.
Strongly typed definition language may be slightly slower than weak type definition language, but the rigor of strong type definition language can effectively avoid many errors. In addition, "The language is not a dynamic language" and "the language is the type of security" is completely no connection between! For example: Python is a dynamic language and is a strongly typed definition language (type-safe language); VBScript is a dynamic language and is a weak type definition language (type unsafe language); Java is a static language and is a strongly typed definition language (type-safe language).
(5) explanatory type: interpreted and compiled correspondence, is a kind of programming language translation way, through these ways programming language conversion to computer can directly run machine code
The high-level language used in programming is not directly understood by the computer and must be translated into machine language by some means, so that the computer can run programs written in high-level languages. There are two ways of translating, one is compiling, the other is interpreting.
A compiled type is a compiler that compiles the source program into a machine language and saves it as a binary file, and then the computer can execute EG:C, C + +, GO, Swift, Object-c, Pascal
Explanatory type refers to the source code is not directly translated into machine language, but the use of specialized interpreters on the source program to the specific platform to interpret the machine code and immediately execute Eg:python, JavaScript, Ruby, PHP, Perl, VBScript both ways have their own advantages and disadvantages:
compile-language :
Pros: Compilers typically have pre-compiled procedures to optimize code. Because the compilation is done only once, the runtime does not need to compile, so the program execution of the compiled language is highly efficient. Can run independently from the language environment.
Cons: After compilation, the entire module needs to be recompiled if modifications are required. When compiling the machine code according to the corresponding running environment, porting between different operating systems will be problematic, and you need to compile different executables according to the operating system environment you are running.
interpreted language :
Advantages: Good platform compatibility, can be run in any environment, provided that the interpreter (virtual machine) installed, flexible, modify the code when the direct modification can be quickly deployed, without downtime maintenance.
Cons: Every time you run, you have to explain it again, performance is not as good as the compiled language.
Mixed language : In fact, it is a combination of the above two translation methods introduced language Eg:java, C #
The Java:java program is compiled into an intermediate code (bytecode format) on the Java platform, and at runtime, the bytecode is executed through the Java Virtual machine, and the bytecode is interpreted as a machine instruction execution on a specific platform. Java combines the compilation and interpretation process. The Java source is first compiled into a class file, and then the class file is interpreted by the virtual machine (JVM), which is why Java can "compile once, run everywhere"
C #: Like Java, it is compiled into intermediate code and then passed. NETFramework virtual machines-known as the Common Language runtime (CLR)-Execute. All of them. NET programming language is compiled into this intermediate code called MSIL (Microsoft Intermediate Language). Therefore, although the final program still has a ". exe" suffix on the surface, the executable file in the traditional sense. In practice, however, if the. Net Framework is not installed on your computer, these programs will not be able to be executed. When the program executes, the. Net Framework translates the intermediate code into a binary machine code to make it run correctly
(6) Advanced : Python's advanced is not relative to assembly language, but relative to the C, C + +, Java and other high-level languages.
Python provides more powerful support for developers at the language level. Any application with a certain size needs to use a data structure such as a linked list, a dictionary, and in Python, a list, Set, and dictionary are built into the data structure and can be used directly. Providing these important building blocks in the core language of Python encourages people to use them, shorten development time and code, and produce more readable code. In languages such as C + +, these data structures typically need to be implemented with additional standard libraries.
(7) Programming language : programming language is the language used to write the code of the program, the computer is composed of software and hardware, and the software is composed of code and documents, programming language can be understood as a rule, a writer can easily understand the rules of the Code. The code communicates with the computer in some way (above the compilation and interpretation), giving instructions to the computer and controlling the computer for a series of operations.
(8) glue Language: Glue language refers to the programming language used to connect software components, usually the scripting language.
Python can combine C + +, Java-written modules easily together, so that the C + + for the underlying, Java object-oriented two major advantages of unified into a complete program. Python can connect a variety of key technical standards like a eight-claw fish, such as Shell Command, Windows DLLs, and WebService. In the B/s architecture, today, there have been dozens of Python web development Framework, the development has now formed a Django, Tornado and other mature framework.
(9) Cross -platform: cross-platform refers to the programming language can operate on a variety of operating system computers, without the need to modify the code.
There are 3 main operating systems: Windows, Linux, Mac, and their pros and cons are now probably the following: Windows client is easy to use, Linux wins in stability, MAC provides a better user experience. Python implements the interpreter on each platform, allowing Python programs to run on different operating system platforms.
(10) Robustness : The so-called robustness refers to some non-standard input can be judged that the input is not in line with the requirements of the specification, and has a reasonable way to handle.
Python's strong type mechanism, exception handling, garbage automatic recovery mechanism are the important guarantee of its program robustness. Developers using python don't have to spend too much effort on resource requests, recycling, and so on.
(11) easy to learn and use : Python's design philosophy is: Elegant, clear, simple.
Due to the simplicity, readability 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 begun to use Python to teach programming languages, such as the Carnegie Mellon University's programming base, MIT's Introduction to Computer science and programming is 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.
an important question---- about Python2 and Python3:
Python2 and Python3 are two versions of Python, Python2 has existed for up to more than 20 years, and is doing well in support of third-party libraries, Python3 is a new version that has been slowly launched and rising in the last 10 years, and the official explanation python3 is the future trend, And no longer update python2, as a coder no matter what version of their own, to another version should have a bit of understanding, I personally is optimistic about the future trend, so use is Python3, but later work may encounter some projects are written in Python2, So Python2 also know. For example, there is a functional difference between the byte string (str) in the Python2 and the byte strings in the Python3 (bytes), which is treated as a statement in Python2, and is treated as a function in Python3; Division is different, Python2: 5/2 = 2 PYTHON:5/2 = 2.5; On the encoding, Python 2 uses ASCII by default, while Python3 uses Unicode.
2.python Installation: Describes the installation of Python and the configuration of the environment (note: Here I installed the latest version of Python3 3.7.0)
The Python program will not run until the Python environment is installed, here are the steps to install the Python environment:
(1) Go to the download page of Python's website to download the python installation package URL: https://www.python.org/downloads/, based on your operating system selection
(2) After selecting the operating system to go to the next page, select the appropriate installation package, my own computer is the Windows system, as follows I chose the installation package
(3) The download speed of the official website is really slow, the official website download slow can use I share the installation package download: Link: https://pan.baidu.com/s/1kXmqqJt Password: T0C8
(4) Now to start the installation:
Click on the installation package, then select the following two options, then click Install Now. About add Python to path refers to adding a Python program to a system variable to explain running Python on the command line. Python3 in the installation of the time can be directly added to the environment variable python, and python2 can not be directly added, you must manually add.
Installation Complete:
Detects if the installation was successful and whether Python was added to the system variable: Press the win and R keys at the same time, enter CMD in the Run window that pops up, enter Python in Cmd, and a similar picture appears to indicate success
Introduction, installation and setup of 3.python development tools
Python is downloaded with an official IDE, such as:
The official IDE I personally feel is not very useful, so it is recommended that you learn python in the early days can be used, but the best use of pycharm after the introduction of the Ide,pycharm is a powerful IDE, With a set of tools to help users improve their efficiency when using the Python language, such as debugging, syntax highlighting, project management, code jumps, smart tips, auto-completion, and more, the Pycharm installation is described below.
Note: About Pycharm, as well as Python has two versions, one is the community version, a professional version, Community edition free, but can do less things, professional version to charge, but do more things, can also be cracked. Here I install the Pro version, because some of the individual projects require Professional Edition.
The steps for Pycharm installation are as follows:
(1) Visit the official website to download the installation package, website link: https://www.jetbrains.com/pycharm/website is a foreign site, download relatively slow, too slow to download the official website can use my share of the installation package download: Link: https:// PAN.BAIDU.COM/S/1NW15CNF Password: 089v
(2) Click on Install package to start the installation, click Next to continue the installation:
(3) Select the installation location and click Browse. Can replace the installation location, I personally is the pycharm installed in the non-system disk D drive, select the installation location, click Next, continue to install
(4) If these options are checked, click Next to continue the installation
(5) Keep the default, click Install, continue the installation
(6) The installation is completed as follows, click Run Pycharm, then click Finish, we look at the final installation effect
(7) At this point, after the installation is complete, open the screen as follows, select the following options, and then click OK to continue
(8) Next, you need to enter the activation code, such as select can be activated:
(9) down into the Pycharm welcome interface, here directly click OK to enter the Pycharm, you can also make some settings.
(10) Next is the creation of the project page of Pycharm, the leftmost row is the project category, the creation of the project to choose the right type, on the right is the project location settings and interpreter settings
(11) Enter the Pycharm, set the method, click File, and then click Settings, you can enter the Settings page:
The Settings page is as follows:
(12) Here are some pycharm tips to use:
Tip: Set the creation document at the beginning of a fixed sentence: Say __author__ = ' somebody ' (Somebody for someone's name, you can write your own name), here is a Python file as an example
Go to the following page, choose below, write down the following code:
Once you create a Python file, the author name and date are automatically added to the beginning, as follows:
Tip Two: Use Python to download third-party packages, go to the Settings page and select the following, click on the + sign on the right
After clicking on the plus sign, the following page appears, enter the package name above, find the package and click on the Install pack installation, please tick the option above the install pack
Example:
Python Introduction and installation and setup of Python installation and development tools