正常时输出追踪信息:
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
时间: 2024-12-28 20:59:22