python - 如何停止在 visual studio 代码中执行 python 脚本?

标签 python visual-studio-code

我有以下代码,我使用 Right click > Run Python File in Terminal

从 Visual Studio Code 中运行
import threading


def worker(tid):
    """This is what the thread actually executes"""
    for i in range(tid * 100000):
        print("I'm working on thread {} with count {}".format(tid, i))
    return


def main():
    threads = list()
    for i in range(32):
        t = threading.Thread(target=worker, args=(i,))
        threads.append(t)
        t.start()


if __name__ == "__main__":
    main()

但是我想停止脚本的执行,所以我尝试使用 Ctrl+C 但程序仍在 Visual Studio Code 的集成终端中运行。有没有办法真正强制停止?

最佳答案

集成终端窗口的顶部应该有一个垃圾桶。单击垃圾桶将终止窗口和进程。

您也可以尝试 ctrl-Z 或 ctrl-D。

关于python - 如何停止在 visual studio 代码中执行 python 脚本?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50385276/

相关文章:

python - 将 3 列数据框转换为矩阵

python - 如何将绘图添加到子图 matplotlib

python - 如何在 jupyter 笔记本中使用 Bokeh 将多选小部件链接到数据表?

terminal - VS Code - 表示属性不适用于构建任务

python - 将 alt.Chart() 与来自 google drive url 链接的数据一起使用

python - TensorFlow:将 tf.Dataset 转换为 tf.Tensor

python - 使用 VS Code Python 扩展 - 如何将 python 模块安装到虚拟环境之外的永久位置?

visual-studio-code - Visual Studio代码-在右侧插入新选项卡

tensorflow - 在 virtualenv 中安装 tensorflow 后,vscode 说找不到模块 [ubuntu20.04]

visual-studio-code - 自动关闭 HTML 标签未触发