Python Debug Single-Step debugging

Source: Internet
Author: User

always worry about is the debugging of Python, before writing C are compiled with GDB directly debugging, relaxed and happy. Now it's an interpretive program that doesn't know what to do. With log bar, sometimes is a small program, do not want to write so much code, play screen bar, sometimes the screen turned fast, but also very depressed. Today finally good, saw a useful thing, PDB
method One: Run the python-m pdb myscript.py
(PDB) will automatically stop in the first line, waiting for debugging, you can see the Help
(Pdb) H
explain these key commands

< breakpoint settings
(Pdb) b #断点设置在本py的第10行
or (Pdb) b ots.py:20 #断点设置到 ots.py line 20th
Delete Breakpoint (Pdb) b #查看断点编号
(PDB) CL 2 #删除第2个断点

< operation
(Pdb) n #单步运行
(PDB) s #细点运行 that's going down, method
(Pdb) c #跳到下个断点
< View
(Pdb) p param #查看当前 Variable value
(Pdb) L #查看运行到某处代码
(Pdb) a #查看全部栈内变量

< If the debug on the command line is:
Import PDB
def TT ():
pdb.set_trace ()
For I in range (1, 5):
Print I

<<< tt ()
#这里支持 n P C.
< (3) TT ()
(PDB) n

Python Debug Single-Step debugging

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.