The method for vscode to run python code is: first open vscode and install the plug-in Python; then modify tasks.json in the Python workspace to be run; finally, the shortcut key [Ctrl Shift b] can be used to run it.
1. Install the Python plug-in
After entering the main interface, press Ctrl p
, enter: ext install python
, just download the first one.
After downloading the Python
plug-in, you can use the code auto-completion function when writing Python scripts.
2. Setting up Python
Run
To run Python
in Visual Studio Code
the code needs to be modifiedtasks .json configuration
configuration code, and to modify the tasks.json
configuration code, you must first create a working folder.
To put it simply, different working folders should be oriented to different projects. You can then configure different languages to run by modifying the tasks.json
file in the folder. Therefore, the tasks.json
file will only appear if the working folder is created.
2.1 Create a working folder
Open the resource manager in the main interfaceCtrl Shift E
, click to open the folder, select the folder (there is no available folder, you can open it in the desired folder) Create a new one in the directory).
2.2 Modify the tasks.json
configuration file
Find the tasks.json
configuration file under the .vscode folder and drag it into Visual Studio Make changes in Code
.
You can also directly press Ctrl Shift p
and then enter: task
and select Configure Task Runner.
Choose Others.
Open the file as follows:
Modify the configuration file:
1. Change the "echo" corresponding to the command to "python".
2. The corresponding ["Helloworld"] of args is modified to ["${file}"].
3. Save changes (Ctrl s
).
2.3 Run Python
to test any Python
file in the working folder. Use Ctrl Shift b
to run.
Done!
Recommended tutorial: "VSCode Tutorial"
The above is the detailed content of How to run python code in vscode. For more information, please follow other related articles on the PHP Chinese website!

2022年了,该学会用VSCode debug了!下面本篇文章手把手带大家会习VSCode debug,希望对大家有所帮助!

本篇是VSCode配置文章,手把手教大家怎么在VSCode中配置使用 Geant4 和 Root,希望对大家有所帮助!

本篇文章扒拉一下vscode Prettier的选项,总结分享16个让你的代码变漂亮的属性,希望对大家有所帮助!

“工欲善其事,必先利其器!”,vscode作为前端开发的重要工具,其插件能大幅提升战斗力,精心收集12个插件,总有几款你还未曾拥有。

VSCode中如何开发uni-app?下面本篇文章给大家分享一下VSCode中开发uni-app的教程,这可能是最好、最详细的教程了。快来看看!

VScode中怎么开发置C/C++?怎么配置C/C++环境?下面本篇文章给大家分享一下Windows系统下VScode配置C/C++环境图文教程,希望对大家有所帮助!


Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

AI Hentai Generator
Generate AI Hentai for free.

Hot Article

Hot Tools

mPDF
mPDF is a PHP library that can generate PDF files from UTF-8 encoded HTML. The original author, Ian Back, wrote mPDF to output PDF files "on the fly" from his website and handle different languages. It is slower than original scripts like HTML2FPDF and produces larger files when using Unicode fonts, but supports CSS styles etc. and has a lot of enhancements. Supports almost all languages, including RTL (Arabic and Hebrew) and CJK (Chinese, Japanese and Korean). Supports nested block-level elements (such as P, DIV),

SublimeText3 Linux new version
SublimeText3 Linux latest version

Notepad++7.3.1
Easy-to-use and free code editor

PhpStorm Mac version
The latest (2018.2.1) professional PHP integrated development tool

Dreamweaver CS6
Visual web development tools
