- 我们Linux中默认安装的Python版本有2.7版本和3.6版本的,并且,默认解释Python源文件的解释器也是以Python2版本来解释的
[gongruiyang@localhost Learn_Python]$ python -V
Python 2.7.5
通过命令我们可以看出,默认Python解释器是Python2
我们可以使用以下方法将默认解释器从Python2切换到Python3
- 第一步:用whereis命令找到/usr/bin/python3.6
[gongruiyang@localhost Learn_Python]$ whereis python
python: /usr/bin/python /usr/bin/python2.7 /usr/bin/python3.6 /usr/bin/python3.6m /usr/lib/python2.7 /usr/lib/python3.6 /usr/lib64/python2.7 /usr/lib64/python3.6 /etc/python /usr/include/python2.7 /usr/include/python3.6m /usr/share/man/man1/python.1.gz
- 第二步:使用alias命令切换
[gongruiyang@localhost Learn_Python]$ alias python='/usr/bin/python3.6'
[gongruiyang@localhost Learn_Python]$ python --version
Python 3.6.8
这是Linux就默认使用Python3来解释Python源文件啦