windows下 python2 与python3并存的方法
学习python最为纠结的是:网络上很多2.x的说明,但自己用的是python3.x,linux下通过软链接很轻松地就解决了这一问题,那么,windows下如何呢。google了一下,在stackoverflow下找出了答案:here is a better way of coexistence/launching of Python 2 and Python 3 on Windows
学习python最为纠结的是:网络上很多2.x的说明,但自己用的是python3.x,linux下通过软链接很轻松地就解决了这一问题,那么,windows下如何呢。
google了一下,在stackoverflow下找出了答案:
here is a better way of coexistence/launching of Python 2 and Python 3 on Windows. The Python 3.3 introduced the Python launcher for Windows (see http://www.python.org/dev/peps/pep-0397/).
After installation of Python 3.3, the py.exe
and pyw.exe
is copied to your c:\Windows
directory, and the associations are set for the .py
extension so that it uses the launcher. By default, Python 2 is launched for py script.py
. The py -3 script.py
launches Python 3. (This also means that no path for Python must be added to the environment -- the C:\Windows
already is in the PATH
.)
The best of all is that #!python2
in the script causes lauching via Python 2, the #!python3
causes launching the script via Python 3. This way, you can use scripts for both versions of Python, and you can lauch them the unified way -- py script.py
or by just clicking on the script icon.
There are more details but this is basically what you need.
以上内容就是说,python3.3.msi安装时,会在c:/windows下放置 py.exe, pyw.exe这两个文件,你在cmd下输入,py就是python2.x的执行,py -3就调出了python3.x。
写入博客,以供记忆!
更多推荐
所有评论(0)