之前写python脚本,一直用pycharm这个IDE,效果不错,就是启动慢了点,然后也比较占系统资源。今天忽然发现vscode也能支持py脚本调试,照样代码高亮显示,自动提醒,搜索功能很全,最重要的是,这是轻量级的工具,才~30M,非常好用,这里写下针对python的相关配置:
首先安装python扩展:https://marketplace.visualstudio.com/items?itemName=donjayamanne.python
Installation
Launch VS Code Quick Open (Ctrl+P), paste the following command:ext install python, and press enter.
修改tasks.json就是配置运行环境的,settings.json下的配置能够覆盖VS Code的默认配置,launch.json配置调试环境。
下面是tasks.json的配置
{
// See https://go.microsoft.com/fwlink/?LinkId=733558
// for the documentation about the tasks.json format
"version": "0.1.0",
"command": "python",
"isShellCommand": true,
"args": ["${file}"],
"showOutput": "always"
//"problemMatcher": "$tsc"
}
配置后,按crtl+shift+B执行py文件
让界面显示空格的配置方法:
修改settings.json文件,增加以下配置项
"editor.tabSize": 4, //tab为4个空格
"editor.fontSize": 15, //字体大小
"editor.renderWhitespace": true,
"editor.insertSpaces": true,
"files.exclude": { //在vscode中不显示某些文件
"**/*.pyc":true
}
然后py文件里面就自动显示空格了