python的pdb调试命令的命令整理及实例一、命令整理pdb调试命令完整命令简写命令描述argsa打
python的pdb调试命令的命令整理及实例
一、命令整理
完整命令 | 简写命令 | 描述 |
args | a | 打印当前函数的参数 |
break | b | 设置断点 |
clear | cl | 清除断点 |
condition | 无 | 设置条件断点 |
continue | c或者cont | 继续运行,知道遇到断点或者脚本结束 |
disable | 无 | 禁用断点 |
enable | 无 | 启用断点 |
help | h | 查看pdb帮助 |
ignore | 无 | 忽略断点 |
jump | j | 跳转到指定行数运行 |
list | l | 列出脚本清单 |
next | n | 执行下条语句,遇到函数不进入其内部 |
p | p | 打印变量值,也可以用print |
quit | q | 退出 pdb |
return | r | 一直运行到函数返回 |
tbreak | 无 | 设置临时断点,断点只中断一次 |
step | s | 执行下一条语句,遇到函数进入其内部 |
where | w | 查看所在的位置 |
! | 无 | 在pdb中执行语句 |
二 pdb实例
E:\python\work>python -m pdb prime.py
> e:\python\work\prime.py(1)<module>()
->import math
(Pdb) list
1->import math
2def isprime(i):
3for t in range(2,int(math.sqrt(i))+1):
4if i % t ==0:
5return0
6else:
7return1
8
9print('100到110之间的素数为:')
10for i in range(100,110):
11if isprime(i):
(Pdb) l 12,15
12print(i)
13
14
15
(Pdb) b 12
Breakpoint1 at e:\python\work\prime.py:12
(Pdb) b 7
Breakpoint2 at e:\python\work\prime.py:7
(Pdb) c
100到110之间的素数为:
> e:\python\work\prime.py(7)isprime()
->return1
(Pdb) c
> e:\python\work\prime.py(12)<module>()
->print(i)
(Pdb) n
101
> e:\python\work\prime.py(10)<module>()
->for i in range(100,110):
(Pdb) n
> e:\python\work\prime.py(11)<module>()
->if isprime(i):
(Pdb) n
> e:\python\work\prime.py(10)<module>()
->for i in range(100,110):
(Pdb) n
> e:\python\work\prime.py(11)<module>()
->if isprime(i):
(Pdb)print i
***SyntaxError:Missing parentheses in call to 'print'
(Pdb) p i
103
(Pdb) where
d:\python36\lib\bdb.py(431)run()
->exec(cmd, globals, locals)
<string>(1)<module>()
> e:\python\work\prime.py(11)<module>()
->if isprime(i):
(Pdb)break
NumTypeDispEnbWhere
1 breakpoint keep yes at e:\python\work\prime.py:12
breakpoint already hit 1 time
2 breakpoint keep yes at e:\python\work\prime.py:7
breakpoint already hit 1 time
(Pdb) disable 1
Disabled breakpoint 1 at e:\python\work\prime.py:12
(Pdb)break
NumTypeDispEnbWhere
1 breakpoint keep no at e:\python\work\prime.py:12
breakpoint already hit 1 time
2 breakpoint keep yes at e:\python\work\prime.py:7
breakpoint already hit 1 time
(Pdb) n
> e:\python\work\prime.py(7)isprime()
->return1
(Pdb) where
d:\python36\lib\bdb.py(431)run()
->exec(cmd, globals, locals)
<string>(1)<module>()
e:\python\work\prime.py(11)<module>()
->if isprime(i):
> e:\python\work\prime.py(7)isprime()
->return1
(Pdb) cl
Clear all breaks? y
Deleted breakpoint 1 at e:\python\work\prime.py:12
Deleted breakpoint 2 at e:\python\work\prime.py:7
(Pdb)break
(Pdb) c
103
105
107
109
The program finished and will be restarted
> e:\python\work\prime.py(1)<module>()
感谢阅读,希望能帮助到大家,谢谢大家对本站的支持!
python的pdb python的pdb调试命令详解