python pdb如何继续下一个x循环数

问题描述 投票:-1回答:1

我需要在python中调试一个for循环,但是在出现错误之前,它需要继续进行多次迭代。

现在我每次都可以在pdb中按'c'前进到下一个迭代,但是我想知道,有没有办法说'c 20'并使其在停止之前继续下一个20个循环?

感谢

python pdb
1个回答
0
投票

首先,请参阅pdb文档。如果失败,请插入一个计数器:

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
    ...
© www.soinside.com 2019 - 2024. All rights reserved.