我有以下代码,我使用 Right click > Run Python File in Terminal
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/