Calling a python script from command line without typing “python” first

前端 未结 6 619
暖寄归人
暖寄归人 2020-11-29 10:27

Question: In command line, how do I call a python script without having to type python in front of the script\'s name? Is this even possible?


Info

6条回答
  •  天命终不由人
    2020-11-29 11:05

    You can prepend a shebang on the first line of the script:

    #!/usr/bin/env python
    

    This will tell your current shell which command to feed the script into.

提交回复
热议问题