After an experiment, I found that it was useless. I still can only run it with python + file names. Or how can I open it? In powershell, I enter the folder where the file is located and enter the file name directly. After the file is added, the file is opened directly instead of running in powershell. Example
After an experiment, I found it useless. I still can only run it with python + file names.
Or how can I open it? In powershell, I enter the folder where the file is located, and enter the file name directly. \ is prompted to open the file directly, instead of running it in powershell.
Reply content: Use the shell in cygwin.
Or Use the unix-Use shebang/hashbang in Windows Command Prompt method.
.
Google searches for "windows shebang" to find the truth. Yes. You can run it in git bash. Power shell doesn't work. If you write python in windows, you 'd better install git bash, which is more convenient.
#! /Usr/bin/env python This is used in * nix environment. It is used to specify the program to be executed and is not applicable to Windows systems. Directly in dos/powershell ,. /xx. py is opened by the program associated with the file. If you are associated with notepad, it is opened by notepad, if python is used for execution (of course, program execution may flash a window soon), the associated program can be set by right-clicking the attribute. Useless. unix-like systems determine the script running mode based on the file header. Windows depends on the file suffix.
You should use python.exe to open the. pyextension file.
If you want to include parameters, this is a professional term called Shebang (Unix)
There are also similar:
#! /Usr/bin/sh
#! The two systems/usr/bin/ruby are designed differently. This line is useless in win.
Like Hu Yanbin, a singer, watching erhu, Li Jian watching Snow White.
It is recommended that you read the * nux getting started book, which is a basic problem. It is similar to the [. ***] of the two platforms.
This sentence means that the program under this directory executes this code, but the path under win is not the same as the * nix path implementation method, so basically, this line of code is useless in win. This can be attributed to the bash of the operating system mingw, and the shell of cygwin.
Therefore, it is ultimately a shell function that has nothing to do with the operating system.
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.