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