Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
如何让 python 调试器 pdb 在退出时中断?另外,我为什么要这样做,我怎样才能打破提出的异常?
覆盖函数:
old_sys_exit = sys.exit def new_sys_exit (value) : print "in sys exit %s" % value old_sys_exit(value) sys.exit = new_sys_exit
然后设置断点:
(Pdb) b new_sys_exit
它也适用于其他调用 sys.modules 的模块。