开发环境
Python是一种跨平台 的编程语言,这意味着它能够在所有的主流操作系统中运行,开发者可以Windows、Linux、Mac中开发和学习Python,甚至在Android手机中也可以运行Python代码。
在所有安装了Pythonr现代计算机上,都能够运行任何Python程序,但是不同的操作系统安装Python的方式有一些差别。在本文章中将使用Windows操作系统搭建Python开发环境,安装和验证步骤如下:
- 下载、安装Python
- 验证安装
- 安装VSCode
- 编写
hello world
程序
安装Python
下载Python安装器
从官网中下载Python安装器,打开Python官网(www.python.org/),点击官网中的Downloads
菜单,进入下载页根据自己的系统和需要Python版本下载Python安装器:
本文中使用最新的Python 3.11.5 版本,直接点击
Download Python 3.11.5
即可下载

安装Python
- 双击安装程序:
python-xx-xx.exe

- 安装时勾上
Add python.exe to PATH
,然后点击Install Now
等待安装完成

安装完成后安装器会提示安装成功,单击Close
就可以:

验证安装
- 使用快捷键
Win + R
开发运行窗口:

- 在运行窗口中输入
cmd
开发命令行窗口:

- 打开命令行窗口后输入
python
然后按下回车键,如果出现了Python提示符(>>>),就说明 Windows安装成功了:
vbnet
C:\Users\yjwfn>python
Python 3.11.5 (tags/v3.11.5:cce6ba9, Aug 24 2023, 14:38:34) [MSC v.1936 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>>
安装VSCode
安装VS Code,先访问Visual Studio Code官方网站:code.visualstudio.com/,单击按钮Download for Windows
下载安装程序,下载完成后双击运行VS Code安装器,安装VS Code。
- 下载VS Code安装器

- 安装VS Code

提示安装完成后,打开VS Code。
给VS Code 安装Python插件
安装完Python和VS Code后,我们开始编写一个Hello World
程序进入Python的编程世界。在开始使用VS Code编写Python程序前,要先为VS Code安装Python插件:
- 单击VS Code应用程序窗口右下角的Manage图标,然后单击 Extensions 选项:

- 然后搜索Python插件

- 单击搜索的Python插件后,进入插件详情,单击
Install
安装Python插件

运行程序 hello_world.py
启动VS Code,选择菜单File > New File
或者按Ctrl + N
新建一个文件,然后将文件保存起来命名为hello_world.py
。保存文件后,在其中输入如下代码:
bash
print("Hello Python world!")
要运行这个程序,选择菜单 Run > Run Without Debugging
:

在VS Code应用程序窗口的底部将出现一个终端窗口,其中包含程序的输出:

总结
本文使用Windows操作系统 + VS Code搭建开发环境,Python的环境的安装和搭建非常的简单,小伙伴们想学Python的赶紧动手起来。