1.问题描述
在传递参数时报错。
An exception has occurred, use %tb to see the full traceback.
SystemExit: 2
/home/zhenhengdong/anaconda3/lib/python3.9/site-packages/IPython/core/interactiveshell.py:3377: UserWarning: To exit: use 'exit', 'quit', or Ctrl-D.
warn("To exit: use 'exit', 'quit', or Ctrl-D.", stacklevel=1)
原因:
由于在jupyter notebook中,args不为空。
2.解决办法
添加 args=[]
args = parser.parse_args(args=[])