Visual Studio Code is not showing the ouput of Python
Visual Studio Code is not showing the ouput of Python
回答1
Using the Python Extension Run/Debug commands
Notes
-
I recommend reviewing the official Visual Studio Code Python documentation and tutorial. That provides several of the basics, with running and debugging the "official" way.
-
There are multiple ways to configure built-in launches:
- When running or debugging Python in VS Code, there are a few options that you can change in your "launch.json" file. See this answer for more details.
Run or Debug with the built-in Python extension commands
You can run or debug using an icon and dropdown in the upper right of your editor window, when editing a python script file.
直接用这里的Run Python File,会在terminal里面执行Python文件,就可以看到输出了
You may need to setup a run/debug configuration to use this (see below), or it may automatically step you through creating one.
The output will normally go to a new "Python" terminal in the "terminal" window (Ctrl-` to open it). See this answer for how to change that behavior.
Setting up a run/debug configuration
Easy option:
- Use the menu item **
Run/Add Configuration
, and follow the prompts at the top of the VS Code window. - Some of the additional details are shown below.
More involved option:
- Click the run/debug icon on the left vertical icon toolbar.
- The window says "RUN AND DEBUG" at the top, with a drop-down that shows "No Configurations" for a given folder or workspace until you set this up.
- The gear to the right of the dropdown will have a red dot if you need to configure this:
Updated Image (1/2022) - Changed from just 'Debug' to 'Run and Debug':
- Click the gear icon (or in the menu, use Run/Open Configurations), and in the middle at the top, Visual Studio Code will open a window titled "Select a debug configuration".
- The available options will depend on exactly how you have Visual Studio Code setup and configured
- There should at least be a "Python File" option with the Python extension installed. Select it.
Now your debug configuration box on the top left of the debug pane should say "Python: Current File":
Visual Studio Code will add a file to your current workspace or working folder called .vscode/launch.json
, and opened it for edit.
作者:Chuck Lu GitHub |
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· 全程不用写代码,我用AI程序员写了一个飞机大战
· DeepSeek 开源周回顾「GitHub 热点速览」
· MongoDB 8.0这个新功能碉堡了,比商业数据库还牛
· 记一次.NET内存居高不下排查解决与启示
· 白话解读 Dapr 1.15:你的「微服务管家」又秀新绝活了
2021-09-17 向量内积(点乘)和外积(叉乘)概念及几何意义
2021-09-17 jQuery Migrate
2021-09-17 Best way to expose resource strings to JavaScript files in ASP.NET MVC?
2021-09-17 What's the difference between sweetalert and sweetalert2?
2021-09-17 Does javascript have an Equivalent to C#s HttpUtility.HtmlEncode? [duplicate]
2021-09-17 sweetalert2 and xss
2021-09-17 上海居住证办理条件以及流程?