- The Python Apprentice
- Robert Smallshire Austin Bingham
- 136字
- 2021-07-02 22:17:02
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.
推薦閱讀
- 解構(gòu)產(chǎn)品經(jīng)理:互聯(lián)網(wǎng)產(chǎn)品策劃入門寶典
- 深入理解Bootstrap
- Apache ZooKeeper Essentials
- Cocos2d-x游戲開發(fā):手把手教你Lua語言的編程方法
- 深入實踐Spring Boot
- Three.js開發(fā)指南:基于WebGL和HTML5在網(wǎng)頁上渲染3D圖形和動畫(原書第3版)
- 精通Python自然語言處理
- C++ 從入門到項目實踐(超值版)
- Modular Programming in Java 9
- 區(qū)塊鏈底層設(shè)計Java實戰(zhàn)
- OpenGL Data Visualization Cookbook
- Learning Continuous Integration with TeamCity
- MongoDB Cookbook(Second Edition)
- Kohana 3.0 Beginner's Guide
- Java核心技術(shù)速學(xué)版(第3版)