官术网_书友最值得收藏!

Executable Python programs on Windows

Starting with Python 3.3, Python on Windows also supports the use of the shebang to make Python scripts directly executable with the correct version of the Python interpreter, even to the extent that shebangs that look like they should only work on Unix-like systems will work as expected on Windows. This works because Windows Python distributions now use a program called PyLauncher. PyLauncher, the executable for which is called simply py.exe, will parse the shebang and locate the appropriate version of Python.

For example, on Windows at the cmd prompt, this command will be sufficient to run your script with Python 3 (even if you also have Python 2 installed):

> words.py http://sixty-north.com/c/t.txt

In Powershell the equivalent is:

PS> .\words.py http://sixty-north.com/c/t.txt

You can read more about PyLauncher in PEP 397.

主站蜘蛛池模板: 武穴市| 东山县| 鸡东县| 武乡县| 贵港市| 隆化县| 临朐县| 璧山县| 三都| 江陵县| 乌鲁木齐市| 汉源县| 张家口市| 保康县| 钟山县| 英吉沙县| 抚松县| 琼海市| 马尔康县| 定日县| 乌恰县| 轮台县| 昭平县| 岳阳县| 同仁县| 香格里拉县| 泾阳县| 临高县| 周口市| 长宁区| 伊金霍洛旗| 贡觉县| 泰宁县| 墨江| 高要市| 枞阳县| 辛集市| 老河口市| 光泽县| 瑞丽市| 土默特右旗|