Python: 配置VS Code编辑器

支持Python的IDE有很多,其中比较知名的有PyCharm,但是像这类IDE通常都比较臃肿,适合大型项目的开发。我们在平时使用中使用一些轻量的工具可能会更方便。本文介绍如何将VS Code配置Python的编辑及运行环境。

安装Python扩展

安装Microsoft自家的Python扩展

Python Microsoft Linting, Debugging (multi-threaded, remote), Intellisense, code formatting, refactoring, unit tests, snippets, and more.

配置VS Code运行Task

在VS Code中配置Task之后,可以直接使command+shift+B运行Python脚本,非常方便。
新建tasks.json文件,并输入如下内容:

{
    "version": "0.1.0",
    "command": "/usr/bin/python3",
    "isShellCommand": false,
    "args": ["${file}"],
    "showOutput": "always",
    "options": {
        "env": {
            "PYTHONIOENCODING": "UTF-8"
        }
    }
}

如此配置的Task只对当前项目有效。

posted @ 2020-07-05 15:09  NZACH  阅读(195)  评论(0)    收藏  举报