python - 根据条件退出 Jupyter Notebook .ipynb 单元
问题描述
from sys import exit
import sys
i=0
while i < 10:
print(i)
i=i+1
if i==5:
exit(0)
print(' i do not want to print this')
基于上面的代码片段,我希望退出 Jupyter Notebook 单元。
我得到的错误是:
/usr/local/lib/python3.6/site-packages/IPython/core/interactiveshell.py:3275: UserWarning: To exit: use 'exit', 'quit', or Ctrl-D.
warn("To exit: use 'exit', 'quit', or Ctrl-D.", stacklevel=1)
我试过了
sys.exit(0)
但仍然无法优雅地退出执行
An exception has occurred, use %tb to see the full traceback.
SystemExit: 0
解决方案
推荐阅读
- oracle - PLSQL oracle 的 FOR 循环中是否需要保存点?
- intellij-idea - 如何在 IntelliJ CLion 中清理编译器文件 *.d?
- rsync - 是否有关于 rdiff/rsync 工作原理的简单解释?
- wpf - WPF - IsPressed 上带有边框、图像和触发器的按钮
- asp.net - 如何仅在文本框中输入内容时应用正则表达式验证
- c# - OBB 碰撞检测错误地检测平移向量
- php - 试图在我的 php 页面上发布 2 个选择查询的结果
- amazon-web-services - 如何将文件传输到 VPC 中可用的 AWS PRIVATE Ec2 实例?
- apache-spark - TIMESTAMP 在蜂巢中与镶木地板的行为不符
- hive - Hive SQL - 条件计数