Vscode is Microsoft last year launched a lightweight editor, functionally and Atom, Sublime Text, vim similar, you can configure it to make the appropriate IDE, here is a brief introduction, the need for friends can refer to the next
First, software download and installation
Vscode Download Address: https://code.visualstudio.com/
Vscode's GitHub project address (not available in this article): Https://github.com/microsoft/vscode
Python Download Address: https://www.python.org/downloads/
I use the win version of the VScode1.0 and 32-bit Python2.7, when installing Python note python added to the system environment variables
Ii. Introduction to the structure of Vscode project
Vscode use folder-named items, that is, you want to write programs, you need to create a new folder as your project, this folder to devolve your source files, if necessary to run, You will also need to create a new. Vscode folder under this folder and configure how the project works under the. Vscode folder.
The following is a typical project structure
├─ Project name ││ source file 1││ source file 2││ ... ││ source Files n│││└─.vscode│ tasks.json│ Settings.json
This configuration pit more, Vscode proposed to change the region to en-us, otherwise, some commands you must play Chinese, can not play English, Chinese display English results, playing English no results.
Of course, this article did not change the area
Third, install the Python plugin
Installing the Python plugin can implement some of the syntax hints, it is recommended to install it.
Open Vscode, view--command panel ( Ctrl+Shit+P
), enter ext install
(Chinese input: extension, then select extensions: Install extension), select Find Python in the search results that appear, and the small cloud on the right of the dot can be installed.
Iv. new project and edit source code
New project is to create a new folder, the author first in the D disk to create a new PythonProject01 folder (this step in the system built, not Vscode), click on the Vscode Explorer button, click the Blue Open Folder button
Locate the newly created folder in the D drive and click Select Folder
Click the new File button, the file name is filled hello.py
In the edit window on the right, enter the following code to save
#-*-Coding:utf-8-*- print "hello,world!" print "Hello, world!" "
V. Edit the Task.json task file and run the program
View--command panel ( Ctrl+Shit+P
), enter tasks: Configure Task Runner
(Chinese Input: task, then select Task: Configure task Run program), select Other
At this point Vscode automatically generates the. Vscode folder and generates a defaulttask.json
Change the contents of Task.json to the following and save
{ //See http://go.microsoft.com/fwlink/? linkid=733558 //For the documentation about the Tasks.json format "version": "0.1.0", "command": "Python", //"command": "D:\\python27\\python.exe", "Isshellcommand": true, //"args": ["${file}"],//This notation cannot be compiled "args": ["hello.py"], "showoutput": "Always"}
New version
{ //See https://go.microsoft.com/fwlink/? linkid=733558 /For the documentation about the Tasks.json format "version": "2.0.0", "Tasks": [ { "Label": "Echo", "type": "Shell", "command": "D:\\programdata\\anaconda3\\python.exe", "args": [ " 1.py " ], " group ": { " kind ":" Build ", " IsDefault ": True } } ]}
Here's how it works:
View--command panel (ctrl+shit+p), enter Tasks:run build task (Chinese Input: task, then select Task: Run Build Task (CTRL+SHIT+B))
The results are as follows:
Attached: Change language to en-us
Ctrl+shift+p, Input language (Language), select configuration language (Configure Language), Location.json file appears automatically
Add "locale": "en-us", as shown below, to save
{ //defines the display language of the Vscode. //See http://go.microsoft.com/fwlink/?LinkId=761051 for a list of supported languages. //To change the value requires restarting Vscode. "locale": "en-US"}
Restart the Vscode.
If you want to change back to Chinese, change to "locale": "ZH-CN" or delete this Location.json file.