Quote: https://www.jianshu.com/p/506debe61423
Foreword
VScode is a very good IDE, with open source, cross-platform, modular, plug-rich, fast start-up time, high color value, highly customizable, and so excellent qualities, Microsoft is indeed the father of an illegitimate child.
So with VScode to write Python, it is quite easy to use.
So, today we have to say something about, how to configure Python development environment on VScode.
Software ready
First, we must first download the installation package and VScode good Python installation package.
Download the following address:
Python: https://www.python.org/downloads/
VSCode: https://code.visualstudio.com/
everyone to choose their own version of the download.
I Windows10 64-bit operating system, so I Python under the latest version of 64-bit, VSco'de download the latest version of 64-bit.
Here I recommend you choose Python3, rather than Python2.7, but even if you download Python2.7 this tutorial still apply.
Software Installation
Install python
First, we have Python installed to your computer.
Remember, we must remember to check the add environment variables.
Otherwise you have to manually configure the python environment variable.
Specific installation process shown in FIG.
Check whether the installation was successful python
Then, we need to check whether the installation was successful under the python.
Inspection method is as follows:
1. Open cmd, enter python, hit enter.
2, enter import this, enjoy the Zen under the python.
3, exit, enter pip list, check the third-party packages are not correct.
Specific process shown in FIG.
Install third-party packages
By carrying pip python tool, while two mounting configuration package VScode required.
flake8 and yapf
flake8 non-standard checks when writing code places and grammatical errors.
yapf formatting tool is a code, the code can be a key to beautify.
Proceed as follows:
1, in cmd input pip list to check whether the packet needs existing
2, download and install the input pip install flake8 flake8
. 3, the input pip install yapf yapf download and install
specific process shown in FIG.
Installation VScode
VScode installation is very simple, all the way NEXT on it.
as the picture shows:
Configuration VScode
Install python plugin.
1, open VScode, press the shortcut keys Ctrl + Shift + X, into the plugin management page.
2, in the search field, enter python.
3, select the plug-in, click Install.
Creating a project configuration work area
1, create a local folder as the project file.
2, a work area arranged
Click Settings to open the configuration file
配置flake8和yapf并关闭pylint工具。
在工作区域输入以下内容:
{
"python.linting.flake8Enabled": true,
"python.formatting.provider": "yapf",
"python.linting.flake8Args": ["--max-line-length=248"], "python.linting.pylintEnabled": false }
如图所示:
3、编写python文件
新建一个python文件,输入一句
print("Hello VScode")
连续按两次F5执行文件。
如图所示:
4、配置python编译设置
连续按两次F5是不是特别不习惯,没事,我们来改掉它!
很简单只需要将launch.json文件的 "stopOnEntry": true,改为 "stopOnEntry": false。
如图所示:
代码格式化工具yapf
在VSCode中按下快捷键Alt+Shift+F即可自动格式化代码
操作起来特别简单,给大家简单的演示下。
如图:
作者:浪晋
链接:https://www.jianshu.com/p/506debe61423
来源:简书
简书著作权归作者所有,任何形式的转载都请联系作者获得授权并注明出处。