在 Jupyter 中停止程序

Ada*_*ith 6 python python-3.x jupyter-notebook

我正在使用 Jupyter (以前的 iPython Notebooks)环境和Python 3,并且我希望程序提前终止。

通常在 Python 中,我只会执行raise SystemExitor sys.exit()

然而,在 Jupyter 环境中,我陷入了丑陋的消息“发生异常,使用 %tb 查看完整的回溯”。Jupyter 有没有办法告诉程序立即终止而不出错?

谢谢。

小智 0

如果您使用的是 Web 界面,只需点击工具栏中的中断内核按钮即可。这会抛出 aKeyboardInterrupt并立即停止单元格的执行。