[英]How do I find/excute Python Interactive Mode in Visual Studio Code?
I'm unable to find/execute the interactive mode in visual studio code - could you guys step-by-step me?我无法在 Visual Studio 代码中找到/执行交互模式 - 你们能一步一步地告诉我吗? Seems like a ridiculous question, I guess, but none of the waypoints I Googled seem to work;
我想这似乎是一个荒谬的问题,但我在 Google 上搜索的所有航点似乎都不起作用;
I don't have "other windows"我没有“其他窗口”
If there's something I need to install, please let me know.如果有什么我需要安装的,请告诉我。
(Yes, I'm a beginner). (是的,我是初学者)。
In VSCode, you can enter the Python interactive window in the following places:在VSCode中,可以在以下几个地方进入Python交互窗口:
F1 -> Python: Create Python Interactive Window F1 -> Python:创建 Python 交互窗口
This is the Python interactive window that comes with VSCode.这是 VSCode 自带的Python 交互窗口。 You can enter the interactive window without inputting instructions.
无需输入指令即可进入交互窗口。 Please use " Ctrl + Enter " to execute the code:
请使用“ Ctrl + Enter ”执行代码:
Ctrl + Shift + ` Ctrl + Shift + `
This is the cmd window that comes with the VSCode integration computer.这是VSCode集成电脑自带的cmd窗口。 We need to enter the command "
python
" to enter the Python interactive window:我们需要输入命令“
python
”才能进入Python交互窗口:
For more information about using Python in Visual Studio Code
, you can refer to the official VSCode documentation: Python in VSCode .关于在
Visual Studio Code
使用 Python 的更多信息,可以参考 VSCode 官方文档: Python in VSCode 。
If you have the Python extension, you can use the Python Interactive feature (this is a IPython/Jupyter console, which can run parts of your code as 'cells', ie snippets of code executed in one go).如果您有 Python 扩展,您可以使用 Python 交互功能(这是一个 IPython/Jupyter 控制台,它可以将您的部分代码作为“单元”运行,即一次性执行的代码片段)。
This article writes about the interactive window and many more possibilities of using Jupyter in VS Code: https://code.visualstudio.com/docs/python/jupyter-support-py本文介绍了交互式窗口以及在 VS Code 中使用 Jupyter 的更多可能性: https ://code.visualstudio.com/docs/python/jupyter-support-py
When editing Python code, select something and press Shift + Enter
.编辑 Python 代码时,选择某些内容并按
Shift + Enter
。 This will open the interactive window and run your selection as a single cell.这将打开交互式窗口并将您的选择作为单个单元格运行。
I have personally been annoyed many times by accidentally pressing Shift + Enter
instead of Enter
on a line of code which (alone) would be a syntax error.我个人被意外按下惹恼了很多次
Shift + Enter
,而不是Enter
的一行代码,其(单独)将是一个语法错误。 Then, one day I decided to start using this feature consciously.然后,有一天我决定开始有意识地使用这个功能。
Press:按:
Ctrl+`
This opens a system shell (bash, or on Windows: Powershell or cmd).这将打开一个系统外壳(bash,或在 Windows 上:Powershell 或 cmd)。 Run
python
, or ipython
if you have it ( pip install ipython
), and use the interactive window.运行
python
或ipython
如果有)( pip install ipython
),并使用交互式窗口。 In the terminal, you can also execute your script, by typing python myscript.py arguments
.在终端中,您还可以通过键入
python myscript.py arguments
来执行脚本。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.