First, the interpreter and the specified path
On Linux \ Mac, you can use ./ file path run .py files directly
In this case, you need to specify its path at the beginning of the interpreter python file
#!/usr/bin/python
Thus the system directly by the beginning of the file specified python, python interpreter using the specified open .py file
A better approach is to :
#!/usr/bin/env python
Write means specifies the linux environment variables $ PATH down a path where the interpreter named python .py file to open
Benefit is that in different systems, eliminating the error appears confined to a particular path
Note: the beginning of the / usr / bin / env is a program to read and write in Linux environment variables
Second, it shows the encoding type .py file
Before the blog have said, when you save the file to your hard drive, you need to save in coding, what coding, coding open what must save, or else be wrong or garbled.
Therefore, in the second line of the file:
# -*- coding: utf-8 -*-
Role is to tell the python interpreter run time, this file is stored in UTF-8 encoded, to open in UTF-8 encoded. In fact, the beginning of the BOM is similar to a text file.