程序错误异常写入文档中示例

Posted chenxi188

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了程序错误异常写入文档中示例相关的知识,希望对你有一定的参考价值。

import traceback
try:
    raise Exception(这是一个错误信息)
except:
    errFile=open(err.txt,w)
    errFile.write(traceback.format_exc())
    errFile.close()
    print(错误信息已经写入err.txt文件中)

 

以上是关于程序错误异常写入文档中示例的主要内容,如果未能解决你的问题,请参考以下文章