Visual Studio Code搭建python开发环境
2017-01-23 12:19
661 查看
python安装(Mac下自带)
Visual Studio Code 安装
Visual Studio Code 安装python插件
command + P 打开命令输入界面
输入ext install python 安装python插件
安装配置flake8(自动错误检查工具)
python环境中安装flake8 pip install flake8
用户-首选项-工作区设置中修改配置(用户设置也可以) "python.linting.flake8Enabled": true
安装配置yapf(自动格式化代码工具)
python环境安装yapf pip install yapf
用户-首选项-工作区设置中修改配置(用户设置也可以) "python.formatting.provider": "yapf"
Command + shift + F 格式化代码
配置Command + Shift + B 运行代码
打开或新建一个python源文件,按下快捷键
配置vitualenv运行环境
用户-首选项-工作区设置中修改配置(用户设置也可以)"python.pythonPath": "${workspaceRoot}/venv/bin/python"
安装Linting(代码格式检查工具)
python环境中安装linting pip install pylint
安装完python插件后pylint是默认开启的
配置显示空格字符
用户-首选项-工作区设置中修改配置(用户设置也可以)"editor.renderWhitespace": "all"
配置忽略非代码文件显示
用户-首选项-工作区设置中修改配置(用户设置也可以)
"files.exclude":{
"**/.git": true,
"**/.svn": true,
"**/.hg": true,
"**/.DS_Store": true,
"**/*.pyc":true
}
完整工作区配置文件
配置代码片段
Code—首选项—用户代码片段,选择python
在配置文件中,输入想要定义的内容,字段含义如下:
完整配置文件实例如下:
调用方式:在python文件中输入itne回车,则输入定义代码片段
配置快捷键
Code—首选项—键盘映射拓展
配置主题
Code—首选项—颜色主题
Code—首选项—文件图标主题
来自为知笔记(Wiz)
Visual Studio Code 安装
Visual Studio Code 安装python插件
command + P 打开命令输入界面
输入ext install python 安装python插件
安装配置flake8(自动错误检查工具)
python环境中安装flake8 pip install flake8
用户-首选项-工作区设置中修改配置(用户设置也可以) "python.linting.flake8Enabled": true
安装配置yapf(自动格式化代码工具)
python环境安装yapf pip install yapf
用户-首选项-工作区设置中修改配置(用户设置也可以) "python.formatting.provider": "yapf"
Command + shift + F 格式化代码
配置Command + Shift + B 运行代码
打开或新建一个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" }
配置vitualenv运行环境
用户-首选项-工作区设置中修改配置(用户设置也可以)"python.pythonPath": "${workspaceRoot}/venv/bin/python"
安装Linting(代码格式检查工具)
python环境中安装linting pip install pylint
安装完python插件后pylint是默认开启的
配置显示空格字符
用户-首选项-工作区设置中修改配置(用户设置也可以)"editor.renderWhitespace": "all"
配置忽略非代码文件显示
用户-首选项-工作区设置中修改配置(用户设置也可以)
"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
}
}
配置代码片段
Code—首选项—用户代码片段,选择python
在配置文件中,输入想要定义的内容,字段含义如下:
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!"
}
}
调用方式:在python文件中输入itne回车,则输入定义代码片段
配置快捷键
Code—首选项—键盘映射拓展
配置主题
Code—首选项—颜色主题
Code—首选项—文件图标主题
来自为知笔记(Wiz)
相关文章推荐
- 基于Visual Studio Code搭建Python开发环境
- Visual Studio Code搭建python开发环境
- Visual Studio Code搭建python开发环境
- visual studio code配置python开发环境的一点心得
- Windows下visual studio code搭建golang开发环境
- 《算法4》 Windows/Mac环境下使用Visual Studio Code和Orcale JDK1.8开发环境搭建
- TypeScript开发环境搭建-Visual Studio Code
- Visual Studio Code+TDM-GCC搭建面向学生的轻量级C/C++开发环境
- Windows下visual studio code搭建golang开发环境
- NodeJs开发环境搭建之Visual Studio Code(一)
- 使用Visual Studio Code搭建TypeScript开发环境
- Windows下visual studio code搭建golang开发环境
- 初试Visual Studio Code配置Python开发环境
- 如何使用vscode [Visual Studio Code]开发工具来搭建一套TypeScript的开发环境
- 使用Visual Studio Code + Node.js搭建TypeScript开发环境
- Windows下visual studio code搭建golang开发环境
- NodeJs开发环境搭建之Visual Studio Code(二)
- Windows/Mac平台下Visual Studio Code C++开发环境搭建