Python introduction,
What kind of language is Python?
Programming languages are classified from the following perspectives: compiler and interpretation, static and dynamic languages, strong and weak definition languages. What does each classification mean, let's take a look.
What is the difference between compilation and interpretation?
CompilerIt is to compile every statement of the source program into a machine language and save it as a binary file. In this way, the computer can run the program directly in the machine language at a high speed;
WhileInterpreterThe execution speed is not as fast as the compiled program.
This is because computers cannot directly understand and execute the statements we write. They can only recognize machine languages (in binary format)
Compilation type(C, c ++, go ...)
Advantage: the compiler usually has a pre-compilation process to optimize the code. Because only one compilation task is required and no compilation is required during runtime, the execution efficiency of compiled languages is high. It can run independently from the language environment.
Disadvantage: After compilation, you need to re-compile the entire module if you need to modify it. During compilation, machine code is generated based on the corresponding runtime environment. Porting between different operating systems may cause problems. You need to compile different executable files according to the operating system environment.
Interpreted type(JavaScript, Python, PHP ...)
Advantage: it has good platform compatibility and can run in any environment, provided that the interpreter (Virtual Machine) is installed ). Flexible. You can directly modify the code when you modify it. It can be deployed quickly without downtime.
Disadvantage: it must be explained every time it is run. The performance is inferior to that of compiled languages.
Python Interpreter
When writing Python code, we get a Python code.pyA text file with the extension. To run the code, you must run the Python interpreter..pyFile.
After downloading and installing Python 2.7 from the official Python website, we directly obtained an official version of the interpreter CPython. This interpreter is developed in C language, so it is called CPython. RunpythonIs to start the CPython interpreter.
IPython is an interactive interpreter based on CPython. That is to say, IPython only enhances the interaction mode, but the function of executing Python code is exactly the same as that of CPython. For example, although many Chinese browsers have different appearances, the kernel actually calls IE.
CPython>>>As a prompt, while IPython usesIn [Serial number]:As a prompt.
Jython is a Python interpreter running on the Java platform. It can directly compile Python code into Java bytecode for execution.
IronPython is similar to Jython, except IronPython is a Python interpreter running on Microsoft. Net platform. It can directly compile Python code into. Net bytecode.
Python has many interpreters, but CPython is the most widely used. To interact with Java or. Net platforms, the best way is not to use Jython or IronPython, but to interact through network calls to ensure the independence of each program.