Pycharm 简明教程

Pycharm - Debugging and Breakpoints

运行 Python 代码包含两种模式:运行脚本和调试脚本。本章重点介绍使用 PyCharm 调试 Python 脚本。

Running a python code comprises of two modes: running a script and debugging the script. This chapter focusses on debugging the Python script using PyCharm.

Steps Involved

调试 Python 项目的步骤如下所述 −

The steps for debugging the Python project are as explained below −

Step 1

首先按照以下屏幕截图所示调试 Python 项目 −

Start with debugging the Python project as shown in the screenshot below −

debug demo

Step 2

现在,Windows 防火墙要求对 Python 项目进行调试的权限,因为该过程涉及逐行编译。

Now, Windows firewall asks permission for debugging the Python project as the procedure involves line by line compilation.

windows security

Step 3

调试控制台在 PyCharm 编辑器中创建,如下所示,其逐行执行输出。

The debugging console is created in PyCharm editor as shown below which executes the output line by line.

debugging console

运行按钮从一行移动到另一行,以我们想要的方式执行输出。

The run button moves from one line to another to execute the output as the way we want.

run button

Understanding Breakpoints

在调试特定脚本时,故意创建一个断点。断点是有意停止的地方或代码暂停的地方,以便识别特定阶段的输出。

While debugging a particular script, it is intentional to create a breakpoint. Breakpoints are intentional stopping place or the place where the code is paused in order to identify the output at specific stage.

understanding breakpoints

在 PyCharm 中,断点使用指定编辑器中的一个单独对话框可见。它包含各种属性来评估定义的断点并跟踪日志,其主要目的是实现更好的编程实践。

In PyCharm, breakpoints are visible using a separate dialog in the specified editor. It includes various attributes to evaluate the breakpoints defined and tracing log for the same with a main motive to achieve better programming practice.