【工程实践】解决parser.parse_args()报错 --- An exception has occurred, use %tb to see the full traceback.

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=[])

猜你喜欢

转载自blog.csdn.net/weixin_44750512/article/details/129532988