VSCode Python插件核心功能介绍
VSCode Python插件推荐。
微软官方Python插件功能丰富,涵盖代码检查、智能提示及调试等核心需求。
a) Linting (Prospector, Pylint, pycodestyle, Flake8, pylama, pydocstyle, mypy with config files and plugins)静态代码扫描(支持多种linter语法格式检查)
b) Intellisense (autocompletion with support for PEP 484 and PEP 526)智能提示(上下文感知的自动补全)
c) Auto indenting自动缩进
d) Code formatting (autopep8, yapf, with config files)代码自动格式化
e) Code refactoring (Rename, Extract Variable, Extract Method, Sort Imports)代码重构(重命名、提取变量/方法及导入排序)
f) Viewing references, code navigation, view signature查看引用、代码导航及签名
g) Excellent debugging support (remote debugging over SSH, mutliple threads, django, flask)完美的调试支持(SSH远程调试、多线程及Django/Flask支持)
h) Running and debugging Unit tests (unittest, pytest, nose, with config files)运行和调试单元测试
i) Execute file or code in a python terminal在python终端执行文件或代码
j) Snippets代码片段
该插件已满足基本开发需求。例如按Alt+Shift+F可调用autopep8格式化代码(VisualStudio快捷键为Ctrl+K,D)。
为满足个性化Style,可自定义Snippets。输入for后在提示框选择对应snippet:

点击回车或者tab,就变成了:
for target_list in expression_list:
pass
若要定义如`for xx in enumerator()`的快速遍历Snippet,需打开文件—首选项—用户代码片段。选择Python语言后编辑python.json,在根级新增object,内容如下:
"For in enumerator": {
"prefix": "for/enum",
"body": [
"for ${1:index}, ${2:item} in enumerate(${3:array}):",
" ${4:pass}"
],
"description": "For statement with enumerator"
}
这样在我们输入for/enum再按回车后,就自动生成了:
for index, item in enumerate(array):
pass
光标停留在index上并选中该词,我们可以直接修改完,按tab切换到item,然后是array、pass。
Guides:缩进提示
虽然VSCode自带缩进参考线,但Guides插件体验更佳,当前级别缩进线会变红,层级一目了然。

当前所在的级别缩进线会变红,当前在哪一级一目了然。
vscode-icons文件图标集,支持更多文件类型,颜值更高!

关于调试时自动暂停在第一句。
可在lauch.json文件中配置,将”stopOnEntry”:true设置为false即可不再暂停。
其他
此外还有多项Python插件配置,可在设置中搜索获取,包括:
a) autopep8/yapf:自动格式化代码;
b) pylint-django:兼容django的pylint,需用pip install安装;
c) flakes8:错误提示。
希望大家玩得愉快~