python 带参数 单步执行 调试 pdb
发布时间:2023-04-07 15:06:16 所属栏目:教程 来源:
导读:Try:
python -m pdb test.py arg1 arg2
Running python -m pdb runs pdb as a script. If test.py is somewhere in your path rather than your current working directory, this can be a helpful substitute:
python -m pdb test.py arg1 arg2
Running python -m pdb runs pdb as a script. If test.py is somewhere in your path rather than your current working directory, this can be a helpful substitute:
|
Try: python -m pdb test.py arg1 arg2 Running python -m pdb runs pdb as a script. If test.py is somewhere in your path rather than your current working directory, this can be a helpful substitute: python -m pdb "$(which test.py)" arg1 arg2 单步执行代码,通过命令 python -m pdb xxx.py 启动脚本,进入单步执行模式 pdb命令行: 1)进入命令行Debug模式,python -m pdb xxx.py 2)h:(help)帮助 3)w:(where)打印当前执行堆栈 4)d:(down)执行跳转到在当前堆栈的深一层(个人没觉得有什么用处) 5)u:(up)执行跳转到当前堆栈的上一层 6)b:(break)添加断点 b 列出当前所有断点,和断点执行到统计次数 b line_no:当前脚本的line_no行添加断点 b filename:line_no:脚本filename的line_no行添加断点 b function:在函数function的第一条可执行语句处添加断点 7)tbreak:(temporary break)临时断点 在第一次执行到这个断点之后,就自动删除这个断点,用法和b一样 8)cl:(clear)清除断点 cl 清除所有断点 cl bpnumber1 bpnumber2... 清除断点号为bpnumber1,bpnumber2...的断点 cl lineno 清除当前脚本lineno行的断点 cl filename:line_no 清除脚本filename的line_no行的断点 9)disable:停用断点,参数为bpnumber,和cl的区别是,断点依然存在,只是不启用 10)enable:激活断点,参数为bpnumber 11)s:(step)执行下一条命令 如果本句是函数调用,则s会执行到函数的第一句 12)n:(next)执行下一条语句 如果本句是函数调用,则执行函数,接着执行当前执行语句的下一条。 13)r:(return)执行当前运行函数到结束 14)c:(continue)继续执行,直到遇到下一条断点 15)l:(list)列出源码 l 列出当前执行语句周围11条代码 l first 列出first行周围11条代码 l first second 列出first--second范围的代码,如果second<first,second将被解析为行数 16)a:(args)列出当前执行函数的函数 17)p expression:(print)输出expression的值 18)pp expression:好看一点的p expression 19)run:重新启动debug,相当于restart 20)q:(quit)退出debug 21)j lineno:(jump)设置下条执行的语句函数 只能在堆栈的最底层跳转,向后重新执行,向前可直接执行到行号 22)unt:(until)执行到下一行(跳出循环),或者当前堆栈结束 23)condition bpnumber conditon,给断点设置条件,当参数condition返回True的时候bpnumber断点有效,否则bpnumber断点无效 (编辑:汽车网) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |
推荐文章
站长推荐
