[Python] like gdb use the same pdb debug python program

As stated, we want to be like gdb C program like. Python program to debug on the line

Pdb can be used to achieve this function.

See: https://docs.python.org/3/library/pdb.html

The easiest way, we longest_substring.py example.

Execute it using the following way, they entered debug mode:

┬─[tong@T7:~/Src/copyleft/algorithm/string]─[11:37:33 AM]
╰─>$ python -m pdb longest_substring.py a1234 c23d
> /home/tong/Src/copyleft/algorithm/string/longest_substring.py(3)<module>()
-> import sys
(Pdb) b lss
Breakpoint 1 at /home/tong/Src/copyleft/algorithm/string/longest_substring.py:10
(Pdb) r
a1234
c23d
> /home/tong/Src/copyleft/algorithm/string/longest_substring.py(11)lss()
-> la =only (a) 
(bp)

[classic_tong @ https://www.cnblogs.com/hugetong/]

Use as gdb, like command set a breakpoint b, r run the program command, command n Step.

 

Guess you like

Origin www.cnblogs.com/hugetong/p/12155521.html