Introduction to Python program debugging in PDB mode and python debugging in pdb Mode
I used the idel feature in windows to debug python programs. I have not debugged python programs in linux. (Most of the time it's just print) search for it online ~
Method:
Copy codeThe Code is as follows:
Python-m pdb a. py
A. py is a python file.
Common commands in (Pdb) mode:
Q
Exit debug
H is the help, print all commands available
H w
Print the meaning of command w
N
Execute the current row until it reaches the next line or until it returns
S
The execution of the current row may stop as soon as possible (for example, there is a function call in the current row ). The difference between this function and n (next) is that s (step) will stop the execution of the current row when there is a function call in the current row, and n will not stop, until the calculation is complete (to the next line ).
B (reak) [[filename:] lineno | function [, condition]
Set the breakpoint, which can be a row number or function. For example, B 10, B foo, B foo, n = 5. Finally, a breakpoint is set at the entrance of the function foo (), which is valid only when the value of n is 5. When command B has no parameters, all breakpoints are printed.
Tb (reak) [[filename:] lineno | function [, condition]
Temporary breakpoint, only hit once.
Disable [bpnumber [bpnumber...]
Make the breakpoint of the pointing line invalid
Enable [bpnumber [bpnumber...]
Make the breakpoint on the specified row valid
C
Execute the program until the next breakpoint occurs.
W
That is, where: prints the position of the current execution point
L [first, [, last]
Output source code near the current line
P expression
Execute an expression to print its value.
A (rgs)
Print the parameters and values of the current function
<Press enter directly>
Repeat the previous command
If a command is not recognized by pdb, it is executed as a python expression. If you want to execute the expression, add the first! Characters, such! N = 5
Multiple debug commands can be written on one line, separated by two semicolons, such as s; s.