目录
1 How to use PyCharm's debugger effectively.
2 Breakpoints and Debug Session
Basic Code Debugging
基本的代码调试
1 How to use PyCharm's debugger effectively.
1 如何有效使用PyCharm的调试器
In this step, we’ll look at PyCharm’s debugger, specifically how to use it to walk through your running code and to help you find and fix bugs.
在这一步中,我们将研究PyCharm的调试器,特别是如何使用它来遍历运行中的代码,并帮助您查找和修复bug。
2 Breakpoints and Debug Session
2 中断点和调试任务
Everything starts with a breakpoint. Breakpoints are markers that tell the debugger to suspend the execution of a program. To add and remove breakpoints click the gutter in the line where you want to add them. You can also add a breakpoint from the keyboard by leaving the caret at the end of the line and pressing ⌘F8 (macOS) / Ctrl+F8 (Windows/Linux).
一切都始于一个断点。断点是告诉调试器挂起程序执行的标记。若要添加和删除断点,请单击要添加断点的行中的分隔线。您还可以通过在行尾保留插入符号并按#0 #(macOS)/#1 #(Windows/Linux)从键盘添加断点。
In this example we are adding a breakpoint to this if
statement inside our loop, so the program will suspend the execution on each iteration. We can run the program with the debugger by clicking the little bug button at the top of PyCharm. This runs the currently-selected configuration, but under the debugger.
在这个例子中,我们在循环中给这个 if
语句添加了一个断点,所以程序将在每次迭代中挂起执行。我们可以通过单击PyCharm顶部的小bug按钮来运行调试器程序。这将运行当前选定的配置,但在调试器下。
This project was made from the Flask project template, so it had a Flask Run Configuration made from the start. Another way to run the program with the debugger is to right-click inside the editor and select Debug nam