
1.3 选择Python编辑器
工欲善其事,必先利其器。一款优秀的开发工具可以极大地提高工作效率,由于Python语言的脚本特性,使得其几乎可以用任何工具进行开发。目前比较流行的开发工具有Sublime Text、Vim、PyCharm、Eclipse with PyDev等,这些工具各有优势,开发人员可以根据个人喜好进行选择。
由于本书所有示例代码均基于Windows平台,所以选择Visual Studio Code进行代码编写。Visual Studio Code是微软近年来推出的一款轻量级代码编辑器,它继承了Visual Studio的很多优点,如语法高亮、可定制热键、括号匹配、代码片段收集等实用功能,同时又提供了对Linux平台的支持,使得众多Windows平台开发人员可以轻松地转移到Linux平台,此外还可以通过安装插件的方式使Visual Studio Code对不同语言进行支持。
Visual Studio Code官方下载地址为https://code.visualstudio.com/Download。
下载安装,如图1-12所示。

图1-12
接受许可协议,如图1-13所示。

图1-13
选择安装路径,如图1-14所示。

图1-14
选择开始菜单,如图1-15所示。

图1-15
根据个人喜好选择其他设置,如图1-16所示。

图1-16
准备就绪,如图1-17所示。

图1-17
等待安装结束,如图1-18所示。

图1-18
安装结束,如图1-19所示。

图1-19
首次打开VS Code,如图1-20所示。

图1-20
开始之前先安装对Python的支持,在自定义栏选择Python安装,此时提示栏出现安装确认,如图1-21所示。

图1-21
单击“确定”按钮开始安装。
安装结束,单击左侧导航栏中的“扩展”按钮,查看已安装插件,如图1-22所示。

图1-22
创建一个Python文件,用VS Code打开该文件所属文件夹,单击“调试”菜单,在该文件夹下会自动生成一个.vscode文件夹,其中包括一个launch.json文件,该文件记录了Python相关的配置信息,如图1-23所示。

图1-23
到目前为止,Python开发环境已经配置完成。