我喜欢使用以下方式检查
Python脚本中的错误:
$python3 -m pdb my_script.py
这会让我进入一个pdb提示,从那里我可以继续执行,当它遇到错误,我可以检查变量,然后q退出脚本执行以回到我的shell.
我尝试与iPython调试器模块相同,因为它更加丰富多彩:
$python3 -m ipdb my_script.py
但是,一旦检查到错误,我就无法退出调试器.使用q quit命令只是在重新执行脚本和验尸模式之间切换它:
$python3 -m ipdb my_script.py
ipdb> c
Uncaught exception. Entering post mortem debugging
Running 'cont' or 'step' will restart the program
ipdb> Inspect some variables at this point
ipdb> q
Post mortem debugger finished. The my_script.py will be restarted
ipdb> q
Uncaught exception. Entering post mortem debugging
Running 'cont' or 'step' will restart the program
ipdb> q
Post mortem debugger finished. The my_script.py will be restarted
ipdb> q
Uncaught exception. Entering post mortem debugging
Running 'cont' or 'step' will restart the program
ipdb> q
Post mortem debugger finished. The my_script.py will be restarted
ipdb> q
Uncaught exception. Entering post mortem debugging
Running 'cont' or 'step' will restart the program
如何退出这个调试器?