打开或新建一个python源文件,按下快捷键Ctrl+Shift+B运行,VSC会提示No task runner configured.,点击“Configure Task Runner”,选择“Others”,输入以下内容并保存:
{
// See https://go.microsoft.com/fwlink/?LinkId=733558
// for the documentation about the tasks.json format
"version": "0.1.0",
"command": "${workspaceRoot}/venv/bin/python",
"isShellCommand": true,
"args": ["${file}"],
"showOutput": "always"
}
"files.exclude":{"**/.git": true,"**/.svn": true,"**/.hg": true,"**/.DS_Store": true,"**/*.pyc":true}
//将设置放入此文件中以覆盖默认值和用户设置。{"python.pythonPath":"${workspaceRoot}/venv/bin/python","editor.renderWhitespace":"all","python.linting.pylintEnabled": false,"python.linting.flake8Enabled": true,"python.formatting.provider":"yapf",//配置 glob 模式以排除文件和文件夹。"files.exclude":{"**/.git": true,"**/.svn": true,"**/.hg": true,"**/.DS_Store": true,"**/*.pyc":true}}prefix :这个参数是使用代码段的快捷入口,比如这里的log在使用时输入log会有智能感知.
body :这个是代码段的主体.需要设置的代码放在这里,字符串间换行的话使用\r\n换行符隔开.注意如果值里包含特殊字符需要进行转义.
$1 :这个为光标的所在位置.
$2 :使用这个参数后会光标的下一位置将会另起一行,按tab键可进行快速切换
description :代码段描述,在使用智能感知时的描述
{/*//Place your snippets forPython here.Each snippet is defined under a snippet name and has a prefix, body and// description.The prefix is what is used to trigger the snippet and the body will be expanded and inserted.Possible variables are:// $1, $2 for tab stops, $0 for the final cursor position,and ${1:label}, ${2:another}for placeholders.Placeholderswith the // same ids are connected.//Example:"Print to console":{"prefix":"log","body":["console.log(‘$1‘);","$2"],"description":"Log output to console"}*/"Input Note":{"prefix":"itne","body":["‘‘‘","Function Name : diff_Json_Same","Function : 通用比较xx方法","Input Parameters: jsonastr,jsonbstr","Return Value : None","‘‘‘"],"description":"Input the class or function notes!"}}Visual Studio Code搭建python开发环境
原文:http://www.cnblogs.com/ceshisanren/p/6343774.html