The first line of the Python program #!/usr/bin/env Python's role

Source: Internet
Author: User

1. Usually when we write programs in Pycharm, we write #!/usr/bin/env python on the first line.

Such as:

#! /usr/bin/env Python3
#-*-coding:utf-8-*-
#Author xiaoxing
Print ("Hello world!")

The purpose here is to tell the operating system to invoke the Python interpreter when executing this script, in addition to preventing the operating system user from not loading python into the default /usr/bin path. When the system sees this line, it will first find the Python installation path in the env settings , and then call the interpreter under the corresponding path to complete the operation.

2. Also write in the first line of the #!/usr/bin/python(it only takes effect under the Linux system)

Such as:

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

Print ("Hello world!")

The goal is to tell the operating system to invoke the python interpreter under/usr/bin when executing this script . However, if there is no python interpreter under the path , the program will error, so it is recommended to use the first

The first line of the Python program #!/usr/bin/env Python's role

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.