导语:
本文主要介绍了关于python中pdb有哪些调试命令的相关知识,希望可以帮到处于编程学习途中的小伙伴
1. next 执行下一条语句。如果该语句是函数调用,则执行该函数,然后执行当前正在执行的语句的下一条。
def stop_here(self, frame):
...
# 如果frame还没跳出stopframe,永远返回true
if frame is self.stopframe:
if self.stoplineno == -1:
return False
return frame.f_lineno >= self.stoplineno
# 如果frame跳出了stopframe,进入下一个frame,则执行不会中断,一直到跳出到stopframe
# 还有一种情况,如果在return事件中断执行了next,下一次跟踪在上一级frame中,此时上一级frame能跟踪到botframe,中断
while frame is not None and frame is not self.stopframe:
if frame is self.botframe:
return True
frame = frame.f_back
return False
2. step 执行下一条命令。如果这句话是函数调用,s会执行到函数的第一句。
def stop_here(self, frame):
...
# stopframe为None
if frame is self.stopframe:
...
# 当前frame一定会追溯到botframe,返回true
while frame is not None and frame is not self.stopframe:
if frame is self.botframe:
return True
frame = frame.f_back
return False
3、return执行当前运行函数到结束。
def stop_here(self, frame):
...
# 如果当前帧代码顺序执行,下一个frame的lineno==stoplineno
# 如果执行到for循环的最后一行,下一个frame(for循环第一行)的lineno<stoplineno,不会中断。直到for循环执行结束,紧接着的下一行的lineno==stoplineno,执行中断
if frame is self.stopframe:
if self.stoplineno == -1:
return False
return frame.f_lineno >= self.stoplineno
# 如果在非botframe中,会先追溯到stopframe,返回false,同next
while frame is not None and frame is not self.stopframe:
if frame is self.botframe:
return True
frame = frame.f_back
return False
本文教程操作环境:windows7系统、Python 3.9.1,DELL G3电脑。
本文为原创文章,版权归知行编程网所有,欢迎分享本文,转载请保留出处!
你可能也喜欢
- ♥ 庆祝胖五发射成功,让我们用Python来发射火箭吧!12/19
- ♥ 如何判断python是否是目录09/27
- ♥ python中str是什么意思08/16
- ♥ python __dict__ 使用注意事项11/07
- ♥ python如何输出换行符08/17
- ♥ 如何在python中使用列表09/17
内容反馈