代码为:
if __name__ == '__main__':
try:
cc = 10/0
except:
import sys,traceback
print 'begin'
print ''.join(traceback.format_exception(*sys.exc_info()))
print 'end'
=====获取的输出如下:
begin
Traceback (most recent call last):
File "G:codetestcasepython_codepython_case_5srcloghelp.py", line 32, in <module>
cc = 10/0
ZeroDivisionError: integer division or modulo by zero
end