Convert exception error to string

前端 未结 2 658
终归单人心
终归单人心 2021-02-01 14:14

I want to work with the error message from an exception but can\'t seem to convert it to a string. I\'ve read the os library man page but something is not clicking for me.

2条回答
  •  遥遥无期
    2021-02-01 14:58

    In my experience what you want is repr(err), which will return both the exception type and the message.

    str(err) only gives the message.

提交回复
热议问题