1、打开终端窗口,输入python
Python 2.7.10 (default, Jul 15 2017, 17:16:57)
[GCC 4.2.1 Compatible Apple LLVM 9.0.0 (clang-900.0.31)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
提示mac系统版本自带的python版本
退出python方式
1)Ctrl + D
>>> ^D
2)exit()
>>> exit()
2、安装python3 ,官网下载 https://www.python.org/downloads/ 下载最新版本并安装
在终端窗口输入 python3
localhost:~ Leo$ python3
Python 3.6.5 (v3.6.5:f59c0932b4, Mar 28 2018, 03:03:55)
[GCC 4.2.1 (Apple Inc. build 5666) (dot 3)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>>
基于系统自带的python2 和 自行安装的python3 ,在之后,所有命令python,用python3替换
3、检验代码,输入 print ("hello python!")
>>> print ("hello python!")
hello python!>>>
关闭 python 用ctrl+d 或 exit()