在web浏览器中显示错误情况--cgitb

来源:互联网 发布:三菱plc fx3u编程手册 编辑:程序博客网 时间:2024/06/08 08:33

When you write a new script, consider adding these lines:

import cgitbcgitb.enable()

This activates a special exception handler that will display detailed reports in the Web browser if any errors occur.

If you’d rather not show the guts of your program to users of your script, you can have the reports saved to files instead, with code like this:

import cgitbcgitb.enable(display=0, logdir="/tmp")

It’s very helpful to use this feature during script development. The reports produced by cgitb provide information that can save you a lot of time in tracking down bugs. You can always remove the cgitb line later when you have tested your script and are confident that it works correctly.

如以下为第七章中运用cgitb.enable() 浏览器中显示错误的示例:
这里写图片描述

0 0
原创粉丝点击