Why do people write #!/usr/bin/env python on the first line of a Python script?

后端 未结 21 1795
刺人心
刺人心 2020-11-21 06:16

It seems to me like the files run the same without that line.

21条回答
  •  無奈伤痛
    2020-11-21 07:06

    It's recommended way, proposed in documentation:

    2.2.2. Executable Python Scripts

    On BSD’ish Unix systems, Python scripts can be made directly executable, like shell scripts, by putting the line

    #! /usr/bin/env python3.2
    

    from http://docs.python.org/py3k/tutorial/interpreter.html#executable-python-scripts

提交回复
热议问题