Python exception handling - line number

前端 未结 6 1257
感动是毒
感动是毒 2020-12-12 12:24

I\'m using python to evaluate some measured data. Because of many possible results it is difficult to handle or possible combinations. Sometimes an error happens during the

6条回答
  •  Happy的楠姐
    2020-12-12 13:25

    The simplest way is just to use:

    import traceback
    try:
        
    except IndexError:
        traceback.print_exc()
    

    or if using logging:

    import logging
    try:
        
    except IndexError as e:
        logging.exception(e)
    

提交回复
热议问题