正常时输出追踪信息:

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

 

相关文章:

  • 2022-12-23
  • 2021-12-29
  • 2022-12-23
  • 2022-12-23
  • 2021-12-15
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2022-02-11
  • 2021-12-18
  • 2021-11-10
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-03-03
相关资源
相似解决方案