Windows system, the first line #!/usr/bin/env Python is not useless?

Source: Internet
Author: User
Tags shebang
Title
Experiment, found useless, or can only be run with the python+ file name.
Or did I open the wrong way? I entered the folder in PowerShell and then entered the file name directly, prompting Add. \ after the file is opened directly, not in PowerShell running.

Reply content:

You can use the shell in the Cygwin, if you really need it.
Or use the method here Unix-use Shebang/hashbang in Windows Command Prompt
Google search "Windows Shebang" has the truth. Is. You can run it in git bash. Power Shell is no good, if writing Python in Windows is best to install a git bash, it is more convenient.
#!/usr/bin/env Python
This is for the *nix environment, which is used to specify the execution of the program, not for the Windows system. Directly in the dos/powershell,./xx.py, it will be opened with a file association program, if you are associated with Notepad is open, if it is Python is python to execute (of course, the program executes quickly may flash through the window), the associated program can be set by right-click Properties. No, Unix-like systems are based on the file header to determine how the script runs. Windows depends on how the file suffix is opened.


You should set the. py suffix file to open with Python.exe.


If you want to take parameters, this has a professional vocabulary, called shebang (Unix)

There are similar:
#! /usr/bin/sh
#! /usr/bin/ruby Two system design differences, this line in win is useless.

Like I am a singer Yanbin see is erhu, Li Jian see is Snow White.

I suggest you look at *nux's introductory book, a very basic question, with two platform ". * * *" Similar

This sentence means that the program under this directory to execute this code, but the path of win is not the same as the *nix path implementation, so basically this line of code in win is useless. This bash, which is attributed to operating system MinGW, can be used by Cygwin's shell.

So the bottom line is the Shell function, which is not related to the operating system.
  • 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.