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.