Python 环境搭建
系统:windows 7
版本:Python 3.7.3
安装包下载链接:https://www.python.org/downloads/windows/
开始安装
安装前需要先安装Service Pack 1补丁包。(安装方法:https://jingyan.baidu.com/article/db55b609ca4cbe4ba30a2f0e.html)
安装过程建议勾选“Add Python 3.7 to PATH”(将Python 3.7添加到PATH环境变量)并选择自定义安装,在设置“Optional Features”界面最好将“pip”、“tcl/tk”、“Python test suite”等项全部勾选上。
确认 Python 版本
在终端下键入下面的命令查看版本信息:
python --version
也可以在终端输入 python
进入交互式环境,再执行一下代码检查 Python 版本。
import sys
print(sys.version_info)
print(sys.version)
编写 Python 源代码
使用文本编辑工具(可使用Sublime、Atom、TextMate、VSCode等高级文本编辑工具)。
新建hello.py,并在文件中写入:
print('hello, world!')
运行程序
终端切换至源代码所在目录并执行以下命令,看看屏幕上是否输出了 “hello world”。
python hello.py