#!/usr/bin/env python3和# -*- coding: utf-8 -*-

#!/usr/bin python3          
#!/usr/bin/env python3
# -*- coding: utf-8 -*-

#!/usr/bin/env python3 means that the absolute path where the python3 interpreter is located is /usr/bin/python3, which can prevent python2 from interpreting the code of python 3 (there are differences between python2 and python3), but /usr/bin/ Python3 specifies an absolute path. If the python interpreter is not in the path, the script cannot be executed.

Therefore, it is recommended to use the environment variable path #!/usr/bin/env python3, this will go to "PATH environment variable" to find the location of the python3 interpreter, the path is not hard-coded, and then call the interpreter under this path to execute the script .

"#-- coding: utf- 8--" This code indicates that the encoding method is utf-8, because the default encoding in windows is ascii, ken'en may report an error when non-ascii encoding appears in the program.

Guess you like

Origin blog.51cto.com/xxy12345/2542867