Python之异常追踪模块:traceback

正常时输出追踪信息:

import traceback
def stack():
print 'The python stack:'
traceback.print_stack()
from twisted.internet import reactor
reactor.callWhenRunning(stack)
reactor.run() #摘录来自: likebeta. “Twisted与异步编程入门”。 iBooks.

异常时输出异常消息:

import traceback
try:
1/0
except Exception,e:
traceback.print_exc() #摘录来自:http://www.oschina.net/question/565065_122586
上一篇:洛谷 P1032 子串变换


下一篇:java中Class.forName("xxx")和ClassLoader().loadClass("xxx")的区别