首页 > 编程 > Python > 正文

python的pdb调试命令的命令整理及实例

2020-01-04 16:59:12
字体:
来源:转载
供稿:网友

python/146938.html">python的pdb调试命令的命令整理及实例

一、命令整理

 

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) list1->import math2def isprime(i):3for t in range(2,int(math.sqrt(i))+1):4if i % t ==0:5return06else:7return189print('100到110之间的素数为:')10for i in range(100,110):11if isprime(i):(Pdb) l 12,1512print(i)131415(Pdb) b 12Breakpoint1 at e:/python/work/prime.py:12(Pdb) b 7Breakpoint2 at e:/python/work/prime.py:7(Pdb) c100到110之间的素数为:> e:/python/work/prime.py(7)isprime()->return1(Pdb) c> e:/python/work/prime.py(12)<module>()->print(i)(Pdb) n101> 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 i103(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)breakNumTypeDispEnbWhere1  breakpoint  keep yes  at e:/python/work/prime.py:12    breakpoint already hit 1 time2  breakpoint  keep yes  at e:/python/work/prime.py:7    breakpoint already hit 1 time(Pdb) disable 1Disabled breakpoint 1 at e:/python/work/prime.py:12(Pdb)breakNumTypeDispEnbWhere1  breakpoint  keep no  at e:/python/work/prime.py:12    breakpoint already hit 1 time2  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) clClear all breaks? yDeleted breakpoint 1 at e:/python/work/prime.py:12Deleted breakpoint 2 at e:/python/work/prime.py:7(Pdb)break(Pdb) c103105107109The program finished and will be restarted> e:/python/work/prime.py(1)<module>()

感谢阅读,希望能帮助到大家,谢谢大家对本站的支持!

发表评论 共有条评论
用户名: 密码:
验证码: 匿名发表