About Python's first statement

# Usually see in the first line of the script language! / Usr / bin / env python and #! / Usr / bin / python, one of which, the purpose of these two words are pointed out what your python executable file with program to run it.

#! / Usr / bin / python is time to tell the operating system to execute the script, call the python interpreter in the / usr / bin. This code is written in python path dead, that must find an interpreter in the / usr / bin to run the program, but if users do not install the python in the default / usr / bin in the path, then the operating system script when you can not find an interpreter.

#! / Usr / bin / env python in order to avoid the python installed when the user is not in the default / usr / bin path, the python interpreter and can not find the problem. Process: The operating system will first to usr / bin / env python where to find the installation path, and then calls the interpreter program under the corresponding path to complete the operation. The role of this code is to allow the operating system to the environment

Guess you like

Origin www.cnblogs.com/youpeng/p/11466452.html