1 安装Python
大约 1 分钟
本篇是 Python 系列教程第 1 篇,更多内容敬请访问我的 Python 合集
说不定之前安装过,查看已安装Python版本命令
python -V
卸载旧版Python

直接在应用管理里把所有Python相关的都卸载即可
安装最新版Python
官网https://www.python.org/downloads/

若是下载比较慢,没条件开代理可以下载我的资源
https://fanrencode.lanzouo.com/iFvpK27obfch 密码:bacn
双击exe进行安装

选择第二个自定义安装,指定安装路径,下面两个选项也勾选上。

这样就安装成功了!
控制台
在控制台输入python
打开python交互环境,此时就可以运行python代码了

退出是exit()加回车
环境变量
若安装的时候勾选了“add python.exe to PATH”,就会自动把python安装目录添加的path环境变量。
但若输入python却打开了应用商店,原因是Microsoft store路径下面也有个python.exe,而且这个路径也被添加到了path环境变量中。如图:

读取python.exe时,是按照path中的项从上到下读取的,所以我们把自己的python环境变量放到Microsoft store的上方,然后重新打开cmd窗口问题就解决了。
