【问题标题】:How do you break into the debugger from Python source code?如何从 Python 源代码闯入调试器?
【发布时间】:2008-09-29 19:55:12
【问题描述】:

你在 Python 源代码中插入了什么来让它进入 pdb(当执行到达那个位置时)?

【问题讨论】:

    标签: python debugging breakpoints pdb


    【解决方案1】:
    import pdb; pdb.set_trace()
    

    请参阅 Python: Coding in the Debugger for Beginners 了解更多有用的提示。

    【讨论】:

    • 来自the FAQ: > 提出和回答你自己的编程问题也很好,但假装你在危险中:以问题的形式表达它。
    • 如何在 IDE 中工作?它在 Pycharm 中不起作用
    【解决方案2】:

    从 Python 3.7 开始,您可以使用 breakpoint() - https://docs.python.org/3/library/functions.html#breakpoint

    【讨论】:

      猜你喜欢
      • 2015-03-02
      • 1970-01-01
      • 1970-01-01
      • 2021-10-19
      • 2011-01-31
      • 2011-07-22
      • 2015-03-02
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多