Chapter 1 of "Python Core Programming (Second Edition)" from scratch

Chapter 1 Welcome to the Python world

origin

Founded in 1989 by Guido van Rossum

The first release was released in 1991

Interpreted, (byte) compiled language

The code is divided into compiled type and interpreted type. The compiled type such as C and C++ code is "translated" by the compiler before running, and compiled into a binary machine code file. The machine code file is directly executed when the program is executed, which has good efficiency and high performance, but Different operating systems handle binary in different ways, resulting in poor cross-platform performance of compiled languages.

Interpreted code is executed by the interpreter while the code is running. It is executed while translating each time it runs. The efficiency is not as good as the compiled code, but as long as the interpreted language can run on a platform with a corresponding interpreter , good cross-platform.

Python and java are interpreted and byte-compiled languages. After the code is loaded by the interpreter, it will be compiled into an intermediate form of bytecode, such as python's .pyc file, java's .class file, and then executed by the interpreter, which is more efficient than Purely interpreted language is high.

start up

Add the python installation path to the system Path variable, you can directly run the Python interpreter command without entering the full interpreter path

C:\>python myfile.py

run filename directly

You can run Python scripts directly from the filename

linux platform

Add the shell magic string to the first line of the script. The default installation path of python on the linux platform is /usr/local/bin or /usr/bin. When python has been added to the Path system variable, you can directly use /usr/bin/env python Let the system go to the path to find the path of python

#!/usr/bin/env python

windows platform

pass

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=324467332&siteId=291194637