简体   繁体   English

有没有一种方法可以让命令提示符从 Visual Code Studio 运行 python 文件?

[英]Is there a way that command prompt could run a python file from Visual Code Studio?

I was wondering if there is a way the command prompt could run a python file when I click the run button on visual code studio.我想知道当我单击可视代码工作室上的运行按钮时,命令提示符是否可以运行 python 文件。 Is that possible?那可能吗? Thanks in advance.提前致谢。

Yes, that is possible (in fact, a lot of developers and learners do this) and it can be done by following these steps:-是的,这是可能的(事实上,很多开发人员和学习者都这样做),可以通过以下步骤来完成:-

  • Download and install Python on your system and add the bin folder to the path, environment variables.在您的系统上下载并安装 Python 并将 bin 文件夹添加到路径、环境变量中。
  • Install Code Runner Extension from Extension tab in VSCode从 VSCode 的 Extension 选项卡安装 Code Runner Extension
  • Set the configuration of terminal in VSCode to Python将VSCode中终端的配置设置为Python
  • Ctrl+Shift+N is the hotkey to run the Python program in terminal in VSCode. Ctrl+Shift+N 是在 VSCode 的终端中运行 Python 程序的热键。

All you do is enter this into command prompt: PATH OF FILE .您所做的就是将其输入命令提示符: PATH OF FILE For example, if my file was hello.py in Documents, then I would type in C:/Documents/hello.py例如,如果我的文件是 Documents 中的hello.py ,那么我将输入C:/Documents/hello.py

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 更改 Python:在 Visual Studio Code 的终端命令中运行 Python 文件 - Change Python:Run Python File in Terminal command in Visual Studio Code 如何从终端在 Visual Studio 代码中运行 Python 文件? - How to run a Python file in Visual Studio code from the terminal? 从 Visual Studio 打开命令提示符而不是 Powershell 来执行 python - Open command prompt from Visual Studio instead of Powershell for python execution Visual Studio 代码:使用 arguments 运行 Python 文件 - Visual Studio Code: run Python file with arguments 带有 Visual Studio Code 的 Python - 运行特定文件 - Python with Visual Studio Code - Run specific file 是否可以通过命令提示符从C#运行python代码? - Is this possible to run a python code from C# through command prompt? 如何在不显示命令提示符的情况下运行 powershell 中的 python 代码? - How to run python code from powershell with no command prompt showing? 代码在 Visual Studio 代码(python)中以奇怪的方式运行 - Code run in a weird way in Visual Studio code (python) 无法在命令提示符下运行Python代码 - Can't run Python code in Command Prompt 从 Visual Studio 代码调试与从命令提示符运行时,Pygame 程序看起来不同 - Pygame program looking different when debuging from visual studio code versus running from command prompt
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM