This is the third in a series of Python tutorials, for more, check out my Python collection!
Visual Studio Code is very simple to install, so I won't put it here to add more space to the article.
Compared to PyCharm, VSCode is lighter and starts faster. And with the Python plugin can realize the same code hints and highlighting effects as Pycharm.
1 Installation of plug-ins
Installing the plugin is also very easy, open VSCode->expand->search python->install
Restart VSCode once the installation is complete
2 Creating projects
VSCode doesn't have virtual environments like you can create a project directly in PyCharm. in VSCode we have to manually create a project folder and then create a Python virtual environment in this folder.
2.1 Creating folders
Open this folder with VSCode
This way we have an empty project
Create a file and print Hello Python!!!!
Run (right-click Run or tap the Run button in the upper right corner).
Run results:
2.2 Creating virtual environments
First of all, let's talk about what is a virtual environment: the role of a virtual environment is to allow different Python projects to use different Python interpreters, third-party libraries, etc., to isolate the project from the project, and to install packages that do not conflict with each other. For us to learn Python, using a virtual environment is not necessary. If you want to know more about virtual environments, you can check the article "Introduction to Python Virtual Environments" in the column.
How do I create a virtual environment?
Steps:Ctrl+P to open the control panel -> enter>python:
-> Select Create Environment -> Select Venv or Conda -> Select Python Interpreter. Next it's time to start creating
2.3 Configuring debugger and debugging
Debug is a must-have operation during code development, and Python has a Debug mode.
STEP1: Interrupt point. There are two ways to do this, either by clicking directly to the left of the line number, or by placing the mouse on the line and pressing F9.
step2: Select Debugger. Press F5 to open the debugger list and select Python Debugger.
step3: choose the debugger configuration, the first item is "debug the currently selected file".
step4: Click the down arrow next to the Run button in the upper right corner of the file and select Python Debugger: Debug Python File
You can see that you have successfully entered Debug mode