win10安装Python2.7

学习使用的是《learn python the hard way》(译名《笨方法学python》)这本书
中、英版本书籍下载链接

1、安装包下载

python官网官方下载安装包;
本人使用的是win10 64位系统
下载的是2.7.13版本,书上解释是2.7版本各种库支持更全面;

win10安装Python2.7

2、安装和配置环境变量

选择自己需要的路径进行安装;
安装后,将安装路径添加到Path变量中:

win10配置环境变量

2.1. Cortana(小娜)搜索“系统”(控制面板>系统和安全>系统),选择“高级系统设置”

win10安装Python2.7

2.2 在“系统变量”中选择“Path”,双击path后添加安装路径即可

win10安装Python2.7

win10安装Python2.7

win10安装Python2.7

3、打开powershell

同样可以用Cortana搜索“powershell”打开
输入“python”,会看到版本信息

PS C:\Users\GHWJX> python
Python 2.7.13 (v2.7.13:a06454b1afa1, Dec 17 2016, 20:53:40) [MSC v.1500 6
Type “help”, “copyright”, “credits” or “license” for more information.

“Ctrl +Z”退出python

win10安装Python2.7

综上,python安装就完成了。

powershell基本操作

powershell是cmd的升级版;
当前书上只涉及到基本的目录访问和创建操作;

e: //进入E盘
c:// 进入C盘
cd 文件名 //进入文件夹
cd \ //返回根目录
cd.. //返回上一级
md 文件名 //创建文件夹
rm 文件名 //移除文件夹

4、建立第一个项目

使用notepad++新建ex1.py文件,后缀是.py;

print “Hello World!”
print “Hello Again”
print “I love tying this.”
print “This is fun.”
print ‘Yay! Printing.’
print “I’d much rather you ‘not’.”
print ‘I “said” do not touch this.’

在powershell中找到保存ex1.py的文件位置,例如我保存的位置是E:\TODO\python:

e: //打开e盘
cd TODO
cd python //找到程序位置
python ex1.py //执行程序

输出结果

Hello World!
Hello Again
I love tying this.
This is fun.
Yay! Printing.
I’d much rather you ‘n
I “said” do not touch