程序師世界是廣大編程愛好者互助、分享、學習的平台,程序師世界有你更精彩!
首頁
編程語言
C語言|JAVA編程
Python編程
網頁編程
ASP編程|PHP編程
JSP編程
數據庫知識
MYSQL數據庫|SqlServer數據庫
Oracle數據庫|DB2數據庫
您现在的位置: 程式師世界 >> 編程語言 >  >> 更多編程語言 >> Python

Write the correct posture of python with vscode

編輯:Python

Studying recently python, Always used before notepad++ As editor , By chance VSCode They are attracted by its beauty . After using it, I found that it starts quickly , Rich plug-ins , After downloading and installing, you can use it directly with little configuration , And support markdown. Of course , The most important thing is to look good :p design sketch :

hello_world.gif

VSCode Download address

install python plug-in unit

  1. open VSCode,Ctrl+p
  2. Input "ext install python", The search time may be long
  3. Select the plug-in with the highest download volume and click Install ( According to the network , The installation time is uncertain , I've been a beginner for a long time , I have already downloaded it here, so it shows uninstall )

python Plug in installation .gif

This way VSCode You can edit python Code. , After editing the code, press F5 You can run . The first run will let you choose the environment , choice python that will do .

Press default F5 Then you need to press again F5 The program will run , If you want to press F5 Running right now requires that launch.json Of documents "stopOnEntry": true, Change it to "stopOnEntry": false.

Promote plug-ins ,vscode-icons You can make VSCode The Explorer on the left displays icons according to the file type

To configure flake8

install flake8 Later, when writing code, the editor will prompt where there is an error , If the code format is not standardized, it will also prompt

  1. Open the command line
  2. Input "pip install flake8"
  3. install flake8 After success , open VScode, file -> Preferences -> User Settings , stay settings.json Enter... In the file "python.linting.flake8Enabled": true

flake8 To configure .png

flake8 design sketch .gif

To configure yapf

install yapf After the VSCode Press Alt+Shift+F You can format the code automatically

  1. Open the command line
  2. Input "pip install yapf"
  3. install yapf After success , open VSCode, file -> Preferences -> User Settings , stay settings.json Enter... In the file "python.formatting.provider": "yapf"

yapf To configure .png

yapf design sketch .gif

A few tips

  1. View the definition of a function or class Ctrl+ Click the function name or class name with the left mouse button to jump to the definition , Press... On the function name or class name F12 You can do the same thing
  2. Change the variable name Press... On the variable name F2 You can rename variables
  3. python Breakpoint debugging Click on the left side of the line number to set the breakpoint , In the debugging interface on the left, you can view the changes of variables

debug.png

  1. Hide menu bar This is a personal habit , If you also feel that the menu bar is an eyesore , You can click to view -> Switch menu bar , You can hide the menu bar . Press... When you need the menu bar Alt Key to view
  2. Set shortcut key file -> Preferences -> Keyboard shortcuts , Copy the contents of the whole brace of the shortcut key to be modified to the right keybindings.json In file , And then modify “key” The value of is the shortcut key you need . I only modified the shortcut keys for copying a row and deleting a row .

to update

  1. 2016-8-25 to update Introduce two plug-ins
  2. Guides, Indent line plug-in , Make the code look clearer
  3. vscode-todo, send VSCode Support TODO Plug in for

Last

You are welcome to point out what needs to be added or where there are mistakes (。・`ω´・)


  1. 上一篇文章:
  2. 下一篇文章:
Copyright © 程式師世界 All Rights Reserved