How to use PDB to realize Python Program debugging
This article introduces the relevant knowledge of "how to use PDB to achieve Python program debugging". In the operation of actual cases, many people will encounter such a dilemma, so let the editor lead you to learn how to deal with these situations. I hope you can read it carefully and be able to achieve something!
How to debug Python programs?
1. Add breakpoint
Add the red code where you need to insert the breakpoint: if the _ debug value is True, start debugging there (the reason for adding _ DEBUG is to turn debugging on / off).
#! / usr/bin/python _ DEBUG=True def debug_demo (val): if _ DEBUG= = True: import PDB PDB.set_trace () if val