python - 如何在 vscode 中运行几行选定的代码?

标签 python visual-studio-code

如何执行运行 Shift + Enter 仅选择 vscode 中突出显示的代码行?

编辑:也许我应该更清楚。

按 Shift + Enter 时出现以下错误:
Unable to initialize device PRN
但是当我右键单击 > 在终端中运行 python 文件时,代码有效。

最佳答案

Select one or more lines, then press Shift+Enter or right-click and select Run Selection/Line in Python Terminal. This command is convenient for testing just a part of a file.



这就是 VS Code documentation 上的内容对于 Python,这对我有用。是Shift + Enter不是 Ctrl
请注意,这需要 Python 3 extension要安装。

关于python - 如何在 vscode 中运行几行选定的代码?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/59434361/

相关文章:

python - 如何使用 Python 获取字母数字列表中的最高值?

Python:读取 12 位压缩二进制图像

javascript - 从导入的 js 对象文件返回到它在 Visual Studio Code 中被 CMD + 单击的文件

javascript - 支持 Visual Studio Code 中的脚本类型 ="text/babel"

node.js - 在 NPM 上查看我的自述数据时,每个字符之间有一个 �

python - 在 SQLAlchemy 和 MySQL 数据库中使用 blob 作为主键

python - 向量化/优化此 python 代码的最佳方法是什么?

python - 如何在抓取的 Pandas 数据框中的所有列上使用 `str.replace()` 方法?

visual-studio-code - 在没有 Internet 连接的情况下安装 VS-Code 扩展

c++ - Visual Studio Code c++11 扩展警告