简体   繁体   English

python pdb 如何继续下 x 个循环

[英]python pdb how to continue for the next x number of loops

I need to debug a for loop in python but it needs to continue for many iterations before the bug shows up.我需要在 python 中调试一个 for 循环,但它需要在错误出现之前继续进行多次迭代。

Now I could just press 'c' in pdb every time to advance to the next iteration but I was wondering, is there a way to say 'c 20' and make it continue the next 20 loops before stopping?现在我每次都可以在 pdb 中按“c”以进入下一次迭代,但我想知道,有没有办法说“c 20”并让它在停止之前继续下一个 20 个循环?

thanks谢谢

First, see the pdb documentation.首先,请参阅pdb文档。 Failing that, insert a counter:如果做不到这一点,请插入一个计数器:

count = 0
while cond:    # your current loop
    ...
    count += 1
    if count > 20:
        count = 25
        # Put a breakpoint here.
        # When you reach this point, insert any other debugging you want.

    # Code you want to trace
    ...

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM