python怎么切换3_如何从命令行在python 2.7到python 3之间切换?

这篇博客介绍了如何在Windows 7上方便地在Python 2.7和Python 3.3之间切换。通过重命名Python3的可执行文件为python3.exe并添加到环境变量中,用户可以使用python命令执行Python 2.7的脚本,而使用python3命令来运行Python 3.3的脚本。添加Python3到环境变量的方法包括右键点击我的电脑,进入属性,然后修改系统变量的PATH。
摘要由CSDN通过智能技术生成

1586010002-jmsa.png

I'm trying to find the best way to switch between the two python compilers 2.7 to 3.3

If I run python from cmd, I would you use something like

python ex1.py

where I set "python" from window environment variable from my computer properties to point to either python 3.3 or 2.7 one or another.

I am wondering there is an easy way to switch between the two from cmd line ?

解决方案

For Windows 7, I just rename the python.exe from the Python 3 folder to python3.exe and add the path into the environment variables. Using that, I can execute python test_script.py and the script runs with Python 2.7 and when I do python3 test_script.py, it runs the script in Python 3.

To add Python 3 to the environment variables, follow these steps -

Right Click on My Computer and go to Properties.

Go to Advanced System Settings.

Click on Environment Variables and edit PATH and add the path to your Python 3 installation directory.

For example,

k6mzc.png

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值