Python scripts in /usr/bin

后端 未结 5 496
野的像风
野的像风 2021-02-04 04:07

I\'m writing a pretty basic application in python (it\'s only one file at the moment). My question is how do I get it so the python script is able to be run in /usr/bin without

5条回答
  •  小蘑菇
    小蘑菇 (楼主)
    2021-02-04 04:14

    I see in the official Python tutorials, http://docs.python.org/tutorial/index.html, that

    #! /usr/bin/env python
    

    is used just as the answers above suggest. Note that you can also use the following

    #!/usr/bin/python
    

    This is the style you'll see for in shell scripts, like bash scripts. For example

    #!/bin/bash
    

    Seeing that the official tuts go with the first option that is probably your best bet. Consistency in code is something to strive for!

提交回复
热议问题