PDB
The following content is from Baidu Feijiang's tutorial
A sample program
import pdb
import sys
def add(num1=0, num2=0):
return int(num1) + int(num2)
def sub(num1=0, num2=0):
return int(num1) - int(num2)
def main():
#Assuming our inputs are valid numbers
num1 = 33
num2 = 44
pdb.set_trace() # <-- 这个表示添加断点
addition = add(num1, num2)
print (addition)
subtraction = sub(num1, num2)
print (subtraction)
if __name__ == '__main__':
main()
operate
- n Execute the next line
- print p num1, num2
- pdb.set_trace() to set a breakpoint
- b dynamically set the endpoint
- Variables can be allocated dynamically
- quit q
- enter repeats previous command
- c continue
- l current location
- s enters a subroutine
- r run until the end of the subroutine
- a Print the parameters of the current function
- j jump